Background:
I have a database table which is for received_msgs
The table has two columns
id, link_id
If The message is the first one in there (based on criteria) then its link_id is equal to its id.
If it is a reply to a message, its link_id is equal to the id of the message it is in reply to.
Question:
is there any way on the initial insert to set link_id to be the same as the id?
At the moment I am doing the insert and then doing another query, an update, and setting the link_id to be equal to the INSERT_ID
But I dont like using two queries for it.
You could use trigger on
AFTER INSERTaction.But I strongly recommend you to use
NULLfor the root of the adjacency list tree.