Dear Members,
I wish to insert and update conditionally into a table using a single SQL
statement. That is if a record already exists in a table, the statement
should update it, else it should insert it. Probably something like this:
if (select * from UserPoints where username = 'ravi') then
(update UserPoints set points = points + 5 where username = 'ravi')
else
(insert into UserPoints (username, points) values ('ravi', 0))
end if
I can not do it pragmatically using PHP, because the environment is highly
concurrent and it may result in a 'race condition' often.
The version of MySQL we are using is 4.1.14-standard-log.
Please reply soon, it is urgent.
Have a nice day!
Thanks and regards,
Ravi.