I current have the following two queries:
UPDATE `forum_subscriptions` SET `unread`=0 WHERE `userid` = ? AND `threadid` = ?;
And:
SELECT `id` FROM `forum_subscriptions` WHERE `userid` = ? AND `threadid` = ?;
This feels suboptimal.
I know that I can use "affected rows" to find the number of rows that the UPDATE
modified, but if unread
is already zero then "affected rows" will be zero, even if a row was found.
The second query's sole purpose is to find if that row exists.
Is there a way to find out if the UPDATE
query found a row, as opposed to updated a row?