I have the following query:
INSERT INTO table (a) VALUES (0)
ON DUPLICATE KEY UPDATE a=1
I want the ID of either the insert or the update. Usually I run a second query in order to get this as I believe insert_id() only returns the 'inserted' ID and not the updated ID.
Is there a way to INSERT/UPDATE and retrieve the ID of the row without running two queries?
alter table tablename AUTO_INCREMENT = 0;
after the above query, to avoid big gaps in your id values. – Frank Forte