Everything in one query
#1

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.
Reply
#2

You need to run a loop through all the players online. You only have to make 1 query. not a whole lot...
Reply
#3

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'
Reply
#4

Still don't understand here food is one player and will be same to others?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)