Description :
I have an insert query that inserts data perfectly..
Now to keep track of record I have a product_id which is same as the id of the table which is auto increment
the method I am using is I get the last id in the table , increment it and assign the value to product_id.. It works perfectly but there is a bug in my code and that is when the table is empty there is no last id to fetch and increment ...
So by default it gets 0 , increments it to 1 and assigns the value to product id ...
this starts to work perfectly when the query is run again because the second time there actually is last id to fetch
So table looks something like this
what I want is
id | post_id
231 | 1
232 | 232
what I want is
id | post_id
231 | 231
232 | 232
So is there any way that I upon inserting the data could assign the value of id to product_id so they both are equal as if there were two auto increments ... Anyone ??