I have a table with this data
mysql> SELECT * FROM prueba;
+----+------+------+------+
| id | U1 | U2 | cant |
+----+------+------+------+
| 2 | U123 | U124 | 2 |
+----+------+------+------+
I neeed to increment 'cant' in 1 everytime i execute the statement. But if the row doesn't exists it has to be created. The columns U1 and U2 are pairs of data, this means a U1,U2 pair is unique, and thats the condition to search if the record exists.
This is what i have made so far.
select U1,U2,cant,
(
case when exists (select U1,U2 from prueba where U1='U123'
and U2='U124')
then 1
else 0
end
) as tmp
from prueba