I i have a SQL Server database table called tbl_faults. In that table fault_id is a primary(int) and auto incremented. In the same table i have another field called fault_reference (int), and not auto incremented.
When i enter data to the table, fault_reference value should be the same value as fault_id.
Can anyone suggest me a way to do this.
$sql='SELECT Top 1 FROM "tbl_faults" ORDER BY "fault_id"';
I was trying to use this to get the last update value of fault_id and use it when inserting a new row, but this doesn’t seem to work.
I think you can get this by
To update your record I think you can use two methods.
Writing a trigger to update the row once insertion is done
Set fault_reference int NULL Allowed. Then write an update query to update rows fault_reference value as fault_id where fault_reference is NULL.
This is just an idea. Please check.