I have a table in this format:
id | ....... | other_id
-------------------------
1 | ....... | 5
2 | ....... | 2
Basically, when the form is submitted, sometimes there will be a value for other_id
in the form, and the insertion of the new row goes as normal. However, if there is no value given for other_id
, I want its value to come from id
. The issue is that id
is the auto incrementing id, so the actual value of id
is unknown until it's actually inserted into the table.
Is there a way to dynamically do this with SQL itself, without having to run additional queries afterward?