I know that when doing a INSERT IGNORE
duplicate entries are ignored and errors become warning but here is what I need.
Scenario: We have a table with 2 columns (id, name)
where BOTH are UNIQUE
and id
is PRIMARY KEY
.
When you do an INSERT IGNORE
on column name
it creates the next AUTO_INCREMENT
for id
(even though it later doesnt exist in your DB, its just skipped) and when you call LAST_INSERT_ID
it gives you the that next id
. However I need to find the id
that caused the query to be ignore. In other words the id
of the name
that was a duplicate.
Any MySQL/PHP trick is welcomed. :)
Thanks.