I'm trying to make a IF EXISTS UPDATE ELSE INSERT
statement but I get errors around the UPDATE
line. I could do this in two separate queries but I'm not sure what would be better.
I've tried to follow this guide but didn't manage to make my query work. https://blog.udemy.com/sql-if-then/
IF EXISTS
(
SELECT 1
FROM `table`
WHERE
`column` = 'value'
)
THEN
(
UPDATE `table` SET
`date` = NOW()
WHERE
`column` = 'value'
)
ELSE
(
INSERT INTO `table` SET
`date` = NOW(),
`column` = 'value'
)
END IF
END