My problem is similar to the one in this question: MySQL ON DUPLICATE KEY - last insert id?
I have a Tag table in MYSQL with three columns. tagid, tagname and topicid and another irrelevant table. I insert first into the irrelevant table and then when user selects a couple of tags, I use insert ignore to insert these tags into the tag table.
After insertion I do a select LAST_INSERT_ID() to get the tagid of the last inserted tag. But if it's a duplicate tag insertion is ignored and I end up with the id of the record inserted into the irrelevant table instead of a 0 value which I could have used to deduce that the last tag I inserted was a duplicate tag. Like the solution proposed in that question.
So my question is, how do I get the primary key of the tag record which already exists in this scenario after insert ignore?