Welcome Guest, Not a member yet? Register   Sign In
Update and select a row in one database request
(This post was last modified: 06-17-2023, 03:17 AM by Muzikant.)

Hi. I have a MySQL database table players with columns id, name and points. I want to update points by incrementing them and select the affected row in one database request.

UPDATE players
SET points = points + 100
WHERE id = 1

SELECT name, points
FROM players
WHERE id = 1

I need it in one request, because there is an assumption, that tens of requests could run per second, so it needs to be really quick.

Is it possible to combine those queries into one, or is it possible to run them at once while still getting the result? If so, how to implement it with CodeIgniter 4, especially with query builder? Thank you for your tips.

Messages In This Thread
Update and select a row in one database request - by Muzikant - 06-16-2023, 09:38 AM

Theme © iAndrew 2016 - Forum software by © MyBB