And one of the built-ins work on totally general cases: they restrict you to duplication of unique keys. If you want a general insert-if-not-condition format, you can do your full insert into a temporary table, left join that table against the real table on your general condition and selecting those rows which did *not* match (leaving null in the second-table fields) into a second temporary table (since you can't select and insert into the same table in one query), and then insert that entire second table into the original. Annoying and picky, but you can do the whole thing with no client-side language support and you can even set the DELAYED flag on all three statements. Just watch your synchronization since it's no longer a one-statement operation...
On 27/5/02 at 5:14 pm, Victoria Reznichenko <[EMAIL PROTECTED]> wrote: > Markus, > Monday, May 27, 2002, 4:59:30 PM, you wrote: > > ML> Is there a simple way to do something like INSERT IF NOT EXISTS, > ML> other than first doing a SELECT and checking if it returns any rows? > ML> If not, that would be pretty high up on my whish-list : ) > > You can use IGNORE keyword in INSERT statement, but it's not quite the > same as "INSERT IF NOT EXIST". If you specify IGNORE, any rows that > duplicate an existing PRIMARY or UNIQUE key in the table > will be ignored in INSERT: > http://www.mysql.com/doc/I/N/INSERT.html > > Also check REPLACE statement: > http://www.mysql.com/doc/R/E/REPLACE.html > > ML> Cheers, > ML> Markus > > > > > -- > For technical support contracts, goto https://order.mysql.com/?ref=ensita > This email is sponsored by Ensita.net http://www.ensita.net/ > __ ___ ___ ____ __ > / |/ /_ __/ __/ __ \/ / Victoria Reznichenko > / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] > /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net > <___/ www.mysql.com > > > > > --------------------------------------------------------------------- > 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