Is it possible to connect the duplicate key to another statement.
I just picked some integers (4=4) for the example. In the actuall code I am trying to compare two dates and only if the date in the database row is bigger than the php generated date AND duplicated key it should update unj to 7.
from this:
$sql="INSERT INTO mutable (hid, xsn, unj, for, datetime)
VALUES ('$hid', '$xsn', '$unj', '$for', now()) ON DUPLICATE KEY UPDATE unj=7";
to this:
$sql="INSERT INTO mutable (hid, xsn, unj, for, datetime)
VALUES ('$hid', '$xsn', '$unj', '$for', now()) ON 4=4 AND DUPLICATE KEY UPDATE unj=7";
( ON 4=4 AND ) added.
But this is not working. Is there any way to archive this?
Thank you.
edit: I know I could archive this with using SELECT and then INPUT or UPDATE but I need more efficient code.
ON DUPLICATE KEY UPDATEis specific syntax. What is your goal?on duplicate keywith another value.I replaced the dates with4=4to simplify the question.