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

Reply via email to