SQL query question. - 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: SQL query question. (
/showthread.php?tid=580729)
SQL query question. -
b3nz - 07.07.2015
Hey lads,
let's say there are 3 rows in the table:
Код:
Name ------ Money ------ WantedLevel
Test ------ 1000 ------ 11
Test2 ------ 40000 ------ 20
Test3 ------ 1337 ------ 50
Now, for example, I want to get the highest
Money and
WantedLevel values stored in the database.
so I'd do it this way:
Код:
SELECT MAX(Money), MAX(WantedLevel) FROM `table`
and it'd give
40000, 50
But how do I also get the
Name, which has the biggest
Money and
WantedLevel values? That the output would be
Test2 - 40000, Test3 - 50
Is it possible to do it in the same query posted above? Or do I also to send several other queries, such like:
Код:
SELECT `Name` FROM `table` WHERE `WantedLevel` = 40000
etc.?
Thanks!
Re: SQL query question. -
Sime30 - 07.07.2015
Use a semicolon
; to send multiple queries in one line
Re: SQL query question. -
b3nz - 07.07.2015
AFAIK multiple queries are disabled?
click
Re: SQL query question. -
Sime30 - 07.07.2015
Quote:
Originally Posted by b3nz
AFAIK multiple queries are disabled? click
|
Looks like indeed... Just do multiple queries then, that should be fine.
Re: SQL query question. -
b3nz - 07.07.2015
As I'm not in a hurry to do this, I'll just wait a few days, maybe someone will come up with an idea. Anyway, thanks!
Re: SQL query question. -
Misiur - 07.07.2015
It would be easier if you wanted that in 2 rows, but it can be done using nested queries:
http://sqlfiddle.com/#!9/945e5/7
Re: SQL query question. -
b3nz - 07.07.2015
Thank you! This looks simple to modificate & add more fields to check.