SA-MP Forums Archive
MySQL: Update all values in table from another table - 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: MySQL: Update all values in table from another table (/showthread.php?tid=371519)



MySQL: Update all values in table from another table - kurta999 - 23.08.2012

Hi.

I want to run this result for all players in the table, but I don't know how to do it.

Here's the result, this works, but I only can run it for one row and this is doesn't works with multipie rows.

UPDATE players SET maths = (SELECT COUNT( winner_id) FROM maths)

This will update all data for same value in players table, and this is the problem.


AW: MySQL: Update all values in table from another table - Mellnik - 23.08.2012

sorry i dont understand what you mean


Re: MySQL: Update all values in table from another table - kurta999 - 23.08.2012

Shit, sorry for my bad english.

I want to update the "maths" in `players` table for number of rows for the player reg id from math table, but this will count all reg id in maths table and will update the players table for same value.

Example:

Code:
for(new i; i < MaxPlayerIDInPlayersTable; i++)
{
"UPDATE players SET maths = (SELECT COUNT( winner_id) FROM maths WHERE winner_id = i) WHERE id = i"
}
If there will no idea, i will run similar query with mysql plugin from samp server.. This is not the best idea, but I don't know another result now


AW: MySQL: Update all values in table from another table - Mellnik - 23.08.2012

Now I understand i think....

first tell me which plugin you use


Re: AW: MySQL: Update all values in table from another table - kurta999 - 23.08.2012

Quote:
Originally Posted by Mellnik
View Post
Now I understand i think....

first tell me which plugin you use
BlueG's R7 plugin, but after some calculations run this query in cicle in samp server is impossible, because i have ~90k players..


AW: Re: AW: MySQL: Update all values in table from another table - Mellnik - 23.08.2012

Quote:
Originally Posted by kurta999
View Post
BlueG's R7 plugin, but after some calculations run this query in cicle in samp server is impossible, because i have ~90k players..
LOL
Quote:

I want to update the "maths" in `players` table for number of rows for the player reg id from math table, but this will count all reg id in maths table and will update the players table for same value.

Did i understand that:

1. you want to get the count of all rows in table "math"
2 then you wan to insert received number into "maths" from the table players
?


Re: MySQL: Update all values in table from another table - AndreT - 23.08.2012

UPDATE players SET maths=(SELECT COUNT(winner_id) FROM maths WHERE maths.winner_id=players.id)
What about this one?


Re: MySQL: Update all values in table from another table - kurta999 - 23.08.2012

Quote:
Originally Posted by AndreT
View Post
UPDATE players SET maths=(SELECT COUNT(winner_id) FROM maths WHERE maths.winner_id=players.id)
What about this one?
I'm idiot.. LoL
Thanks!

Very nice, this works!

I now searched for while loop in mysql, and other shits, but this solved my problem.
(I was gave rep for you before few monts, so i don't know now give for this )


Re: MySQL: Update all values in table from another table - TwisT3R - 23.08.2012

kurta lбtom szenvedsz angollal