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 > a quick and simple(?) question about SQL commands

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-08, 20:47
will500 will500 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
Question a quick and simple(?) question about SQL commands

This is a continuation from this thread (another website)

So here is the deal. I am new to mysql but not new to webcode like php/html/flash/ect. I am moving roughly 30,000 users from a vBulliten database (the forum software this forum runs on) into phpprobid software, auction software. Basically signing up 30,000 users to this site for them and then giving them all a $3.00 credit to get the ball rolling. :-)

Okay, so we are dealing with 1 database. The database already has 104 users so we have to add after that.


probid_users = user table moving info into
email = column moving info into
users = user table moving info from
email = column moving info from

I tried using the below script:


INSERT probid_users(
email
)
SELECT u.email
FROM user AS u
LEFT JOIN probid_users AS pu ON pu.email = u.email
WHERE pu.email IS NULL


but all that happens is that is takes 341 seconds and then nothing. Nothing gets moved.

Suggestions?

Oh, and hi, I'm new to the community.
Reply With Quote
  #2 (permalink)  
Old 02-28-08, 22:34
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
suggestion:
Code:
INSERT IGNORE
  INTO probid_users
     ( email )
SELECT email
  FROM user
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-28-08, 22:53
will500 will500 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
Question

Quote:
Originally Posted by r937
suggestion:
Code:
INSERT IGNORE
  INTO probid_users
     ( email )
SELECT email
  FROM user
Thanks! buuut... it added more string than needed, so, remember I am new here, when copying fields must you copy them all at once?

I need to copy several fields....

How do I do this?

Thanks!
Reply With Quote
  #4 (permalink)  
Old 02-28-08, 23:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
"it added more string" does not compute

welcome to dbforums

you will find that if you oversimplify the question, the answer will be oversimplified too

enjoy your stay

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 02-28-08, 23:18
will500 will500 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
lol <3 coders

um, okay I'm trying to copy the user table from my vb forum into my auction software on another url :P for their convenience and it'll jump start the site.

eeep... help..

INSERT probid_users(
email
)
SELECT u.email
FROM user AS u
LEFT JOIN probid_users AS pu ON pu.email = u.email
WHERE pu.email IS NULL

that worked, can we do more than 1 column at a time? and if so how?

Last edited by will500; 02-29-08 at 00:10.
Reply With Quote
  #6 (permalink)  
Old 02-29-08, 02:07
will500 will500 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
I guess I need to know how to get this:

INSERT IGNORE
INTO probid_users
( email )
SELECT email
FROM user

to copy multiple fields at once?
Reply With Quote
  #7 (permalink)  
Old 02-29-08, 03:08
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
SQL is a psuedo engliash language manipulation language
so when you SELECT something you need to explicitly tell it waht to SELECT

columns, or fields are supplied as a comma separated list
INSERT IGNORE
INTO probid_users
(column1,clomun2,column3,....columnN )
SELECT column1,clomun2,column3,....columnN
FROM user

Last edited by healdem; 02-29-08 at 03:14.
Reply With Quote
  #8 (permalink)  
Old 02-29-08, 03:09
will500 will500 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
yes I just found that out too, thank you!
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