[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 method of doing what you propose is to allow MySQL to do it for you by establishing a Foreign Key from table1 to table2. One drawback is that both tables need to be InnoDB (which you may not want to support). What version are you using and what is the possibility of using InnoDB with your appliation?

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

PS: always CC the list on all responses (unless you intentionally mean to take the conversation off-list)
i am using 4.1.x
hmm.. maybe it's easier if i just check the id is in table2 before inserting into table1. not really a big deal just looking to create shortcuts without running multiple queries..


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 9/22/2005


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to