我有一个表,有一个ID
和一个occurrences
列.我想创建一个到db的事务,其中
if ID exists in DB:
occurrences++
else:
insert new row where occurrences = 1
我看到有可能做一个IF-THEN语句,所以我try 这样做:
IF ID = 123 IS NOT NULL THEN
UPDATE occurrences = occurrences +1
ELSE
INSERT INTO entity_table(123, 1)
END IF;