2005/9/23, Gordon Bruce [EMAIL PROTECTED]:
What am I missing
INSERT INTO table1 (column names.)
SELECT VALUES..
FROM table2
WHERE primary id = insert value
You will have to put in your real table name and column names.
nice and easy :-)
--
Pooly
Webzine Rock :
DJ [EMAIL PROTECTED] wrote on 09/23/2005 12:22:58 PM:
i want to insert a row into table1 only if the value being inserted on
table1 exists on table2 primary id.
can i do this with subquery?
thanx.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version:
[EMAIL PROTECTED] wrote:
DJ wrote on 09/23/2005 12:22:58 PM:
i want to insert a row into table1 only if the value being inserted on
table1 exists on table2 primary id.
can i do this with subquery?
thanx.
Depending on what version MySQL you are using, probably not. A very robust
DJ [EMAIL PROTECTED] wrote on 09/23/2005 12:49:35 PM:
[EMAIL PROTECTED] wrote:
DJ wrote on 09/23/2005 12:22:58 PM:
i want to insert a row into table1 only if the value being inserted on
table1 exists on table2 primary id.
can i do this with subquery?
thanx.
Depending
, 2005 11:59 AM
To: DJ
Cc: mysql@lists.mysql.com
Subject: Re: insert subquery
DJ [EMAIL PROTECTED] wrote on 09/23/2005 12:49:35 PM:
[EMAIL PROTECTED] wrote:
DJ wrote on 09/23/2005 12:22:58 PM:
i want to insert a row into table1 only if the value being inserted
on
table1 exists on table2
: Friday, September 23, 2005 11:59 AM
To: DJ
Cc: mysql@lists.mysql.com
Subject: Re: insert subquery
DJ [EMAIL PROTECTED] wrote on 09/23/2005 12:49:35 PM:
[EMAIL PROTECTED] wrote:
DJ wrote on 09/23/2005 12:22:58 PM:
i want to insert a row into table1 only if the value being
[EMAIL PROTECTED] wrote:
Well, Gordon, looks like you missed the thread. ;-)
Maybe, but his solution is actually pretty close to what the OP wanted
Instead of
INSERT INTO Table1 (...) VALUES ('val1', 'val2', 'val3', ...) something
you do
INSERT INTO Table1 (...)
SELECT 'val1',