I am trying to create a STORED PROCEDURE
that will be used to UPDATE
a table called machine
. This table has three columns (machine_id
, machine_name
and reg_id
).
In aforementioned table,reg_id
(INT
) is a column whose values can be changed for a machine_id
.
I would like to define a QUERY
/PROCEDURE
to check if a reg_id
already exists in that table. If it does, then UPDATE
that row, otherwise INSERT
a new row.
Can someone please help me to write that QUERY
/PROCEDURE
?
Best Answer
Hope This helps, DUPLICATE KEY UPDATE
Work on SQL Fiddle