Listing INSERTs that cause no duplicates by avoiding single SELECTs for
all entries
I insert products into a table using INSERT INTO DBXY.table (category,
title, description, cost, supplier) VALUES (?,?,?,?,?) using a prepared
statement.
supplier is an unique id.
The table can already have entries that have the same category, title,
description, cost and supplier. I want to know, which entries will be
inserted ie those that are no duplicates. I could do a
SELECT * FROM table WHERE (category = PHPcat) AND (title = PHPtitle) AND....
for each entry and if the number of resulting lines is greater than 0 then
we have a duplicate and no new entry. But I think this approach is flawed
for 6000 and more entries. Is there are way to do this at once so I get an
output that contains all new entries without inserting them just now?
No comments:
Post a Comment