That makes sense. Thank you Tore.
Kyle -----Original Message----- From: Tore Bostrup [mailto:[EMAIL PROTECTED]] Sent: Friday, 21 February 2003 01:12 To: Kyle Lange; [EMAIL PROTECTED] Subject: Re: INSERT ... SELECT - A slightly different question The typical syntax for this would be: INSERT INTO phone (personID, phoneNr, email, type) SELECT personID, '1-xxx-xxx-xxxx', \N, 'OFF' FROM persons WHERE lastName='xxxx' HTH, Tore. ----- Original Message ----- From: "Kyle Lange" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 20, 2003 6:59 PM Subject: INSERT ... SELECT - A slightly different question > Hi all, > > I'm trying to load a 1:M table with <n> rows. I've been thru the > manual and discussion list and each comes close but not quite. I'm > trying to load a full table with 4 cols, but one of them needs to be a > key to another table SELECTed enroute. 'LAST_INSERT_ID()' doesn't help > because the main table has also been loaded with <n> rows. > > The 1st row of my statement looks like; > > INSERT INTO phone (personID, phoneNr, email, type) VALUES ((SELECT > personID FROM persons WHERE lastName='xxxx), '1-xxx-xxx-xxxx', \N, > 'OFF'), or > INSERT INTO phone SET personID=(SELECT personID FROM persons WHERE > lastName='xxxx'), phoneNr='1-xxx-xxx-xxxx', email=\N, type='OFF' > or > INSERT INTO phone (personID, phoneNr, email, type) SELECT personID FROM > persons WHERE lastName='xxxx', '1-xxx-xxx-xxxx', \N, 'OFF', > > None of which seem to work. At this point the only alternative I can > see is to multiple 'personID SELECTs each followed by an INSERT INTO > phone. > > Or is there some fundamental SQL or mySQL concept I'm missing please? > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php