If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Data manipulation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-09-04, 17:17
justinb31 justinb31 is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
Data manipulation

I tried searching for this but i'm unsure what to look for.

I'm trying to export 12 select columns from a YaBBSE table into 12 specific columns in a Postnuke table.

Now, I've already done a sql dump and tried reordering the data from YaBBSE to match the PN table, but this is too time consuming with lots of members and their related information.

So I've exported the 12 columns I need from the member table and this is also sorted basically in the order it needs to be inserted. The query I came up with is:

SELECT
`ID_MEMBER` , `memberName` , `realName` , `websiteUrl` , `avatar` , `dateRegistered` , `ICQ` , `location` , `signature` , `AIM` , `YIM` , `MSN` , `bio`
FROM `members`
WHERE 1 LIMIT 0 , 30

to import i've tried the following:
INSERT INTO
`nuke_users`
VALUES (
`pn_uid` , `pn_name` , `pn_uname` , `pn_email` , `pn_url` , `pn_user_avatar` , `pn_user_regdate` , `pn_user_icq` , `pn_user_from` , `pn_user_sig` , `pn_user_aim` , `pn_user_yim` , `pn_user_msnm` , `pn_bio` )

The problem I'm running into is that the column count is less than whats in the table.

FYI of the 30 columns in both tables/databases, only these 12 are similar and therefore "interchangeable"

I would greatly appreciate anyones input. Thanks
Reply With Quote
  #2 (permalink)  
Old 04-09-04, 18:33
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
It looks like the table you are exporting does not have an email column attributed to it while the new table has an email column. Are you adding the info by 'hand' for email into the second table or have you missed a column in your export?

If the table you are exporting doesn't have an email column and you plan on adding that data in later then drop the email column from the new table and add it in place later after you have imported the data. You can tell the column explicitly where it should be inserted in your alter statement.

ALTER table PN ADD email varchar(100) AFTER pn_uname;
Reply With Quote
  #3 (permalink)  
Old 04-09-04, 19:49
justinb31 justinb31 is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks,

Well the missing email column was something I overlooked.

I hadn't actually put the 2 queries together to run back-to-back; I was trying to simplify things and do each step individually, so the extraction went ok, it was 'putting' the data somewhere else that was causing problems - only I wasn't actually putting data anywhere just trying to put the statement together..that's where I went wrong, because from the import statement below I'm trying to put `pn_uid` , `pn_name` etc as the data instead of my intention of 'where the data should go' and than assign data with VALUE. oops

Your reference to dropping the email column helped me realize what I was doing wrong, because from you were mentioned how to manipulate the columns.

Thanks again

Here's how it should be:
INSERT INTO
`nuke_users` ( `pn_uid` , `pn_name` , `pn_uname` , `pn_email` , `pn_url` , `pn_user_avatar` , `pn_user_regdate` , `pn_user_icq` , `pn_user_from` , `pn_user_sig` , `pn_user_aim` , `pn_user_yim` , `pn_user_msnm` , `pn_bio` )

VALUES
( 4, '', 'test-2', 'test-2@tester.com', '', 'blank.gif', '1081439084', '123456789', 'location', 'sig block', 'aim id', 'yim id', 'msnm id', 'bio stuff' )
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On