Is it possible in MySQL to update a single field and select multiple different fields all where a single condition is true, in a single query? I'm not exactly sure of what the proper SQL would be, but I want to merge these two example queries, if it is possible, of course.
Example
An update query:
UPDATE `users` SET `activation`='$activationCode' WHERE `email`='$anEmail'
and a select query:
SELECT `password`,`salt`,`fname`,`email` FROM `users` WHERE `email`='$anEmail'
See the duplicate condition here? Surely it's unnecessary to query a MySQL database twice with duplicate conditions, when I could do it all at once under a single condition?
It's worth noting that $anEmail
and $activationCode
would be previously defined variables in PHP (with the former also being exactly the same through both queries). Cheers.