I am designing a message system.
In the table where I store the messages, the message_id column is auto increment.
I have another column message_reference_id.
I want its default value to be message_id.
How do I set this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t set the default value to the value in another column. Instead if your column is NOT NULL, you could change it to nullable and set the default value to NULL. Then when you select it, use this:
You could even put this in a view.
Alternatively you can create a trigger which updates the value on insert.