Everything in one query - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Everything in one query (
/showthread.php?tid=529573)
Everything in one query -
Banditukas - 02.08.2014
Hi,
It'is possible to make that query i want to update some things, but a lot of players. And i need to create a lot of queries of update and it take a while when update. For ex:
I have in mysql database a fields:
Name | Food
Killer | 5
NoKiller | 10
....
And i do food --, and i need to update this to database, i load how much they have and how i said that ammount of food i make -- and with mysql update i make new food amount, but this make a lot of queries for each player. It'is will be very good to make it in one query taking all players.
Re: Everything in one query -
Blademaster680 - 02.08.2014
You need to run a loop through all the players online. You only have to make 1 query. not a whole lot...
Re: Everything in one query -
Vince - 02.08.2014
You can use SQL's IN() construct, but you will need to create a loop to create the query in the first place, regardless. I might also add that a numeric primary key may be better.
PHP код:
UPDATE table SET food = food - 1 WHERE name IN('Killer', 'NoKiller')
Re: Everything in one query -
Banditukas - 03.08.2014
Still don't understand here food is one player and will be same to others?