mysql - Abort insertion if duplicate -
i want insert 5 new lines in table if , if none of 5 lines there. if 1 of them in table, want abort insertion (without updating anything), , know 1 (or ones) there.
i can think of long ways (such looking if select col1 col1 in (value1,value2,...)
returns anything, , inserting if doesn't)
i guess transactions can this, i'm learning how work. however, don't know if transaction can give me entry(ies) (are) duplicate(s).
with or without transactions, there way in 1 or 2 queries ?
thanks
i doubt there better way solution mentioned: first run select
query , if doesn't return anything, insert
. asked in 1 or 2 queries. 2 queries, pretty efficient in view. can't think of efficient way use transactions this. transactions when have multiple insert
or update
queries, have one.
Comments
Post a Comment