MySQL Forums
Forum List  »  InnoDB

Can insert update a table based on match of one column value?
Posted by: nobody nobody
Date: February 05, 2019 01:18AM


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.

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.