I tried following query :
INSERT INTO `chat_lines` (`channel`, `nick`, `value`)
VALUES ('Alfa', 'Beta', '0')
WHERE NOT EXIST
(
SELECT *
FROM `chat_lines`
WHERE `channel` = 'Alfa' AND `nick` = 'Beta'
);
How can I insert only if record doesn't exist yet?
Channel and nick can't be unique, because one channel can have records with many nicks and one nick can have many channels.
Something like:
(Alfa | Alfa)
(Alfa | Beta)
(Beta | Alfa)
(Beta | Beta).
So, I don't want to have two identical records like
(Alfa|Beta)(Alfa|Beta).
Or maybe there is other way to solve my problem? I just want to create record with specific nick and channel if it doesn't exist, and if it exist, I want to incrase value.
@edit
I tried to use REPLACE
. It works. But... I want to change value = value + 1
. And it is only possible in UPDATE
AFAIK. What can I do?