i insert products table
using insert dbxy.table (category, title, description, cost, supplier) values (?,?,?,?,?)
using prepared statement.
supplier
number.
the table can have entries have same category, title, description, cost , supplier. want know, entries inserted ie no duplicates. a
select * table (category = phpcat) , (title = phptitle) and....
for each entry , if number of resulting lines greater 0 have duplicate , no new entry. think approach flawed 6000 , more entries. there way @ once output contains new entries without inserting them now?
the right way define unique index on table (this equivalent constraint):
create unique index table_allcols on table(category, title, description, cost, supplier);
you can in insert
well:
insert dbxy.table (category, title, description, cost, supplier) select category, title, description, cost, supplier (select ? category,? title, ? description, ? cost, ? supplier) t not exists (select 1 table t2 t2.category = table.category , t2.title = table.title , t2.description = table.description , t2.cost = table.cost , t2.supplier = table.supplier );
edit:
to find list of matches, create temporary table , join between them:
select tt.* temporary_table tt not exists (select 1 table t2 t2.category = tt.category , t2.title = tt.title , t2.description = tt.description , t2.cost = tt.cost , t2.supplier = tt.supplier );