Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1957

Can insert update a table based on match of one column value? (no replies)

$
0
0
Hi,

I have a table with a column readStatus, if the readStatus is true (it has been read), I can update the table for other columns values, otherwise, I need to insert a new row. Obviously, the following command does not work, is there any way I can have a match statement readStatus = true for doing update?

INSERT INTO table (id, timestamp, readStatus) VALUES (id_value, timestamp_value, false) ON DUPLICATE KEY readStatus = true UPDATE id = id_value, timestamp = timestamp_value;

Thank you.

Viewing all articles
Browse latest Browse all 1957


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>