SA-MP Forums Archive
Hard query, MySQL knowers look here. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Hard query, MySQL knowers look here. (/showthread.php?tid=268879)



Hard query, MySQL knowers look here. - WooTFTW - 14.07.2011

The problem is that i have 2 tables, from first table i want to select player id, and player rank from the second i need the player id which i selected in first line, so i could select correct values. I need this in one query. Is this even possible?

how far i got:
pawn Код:
(SELECT id, playerrank FROM characters WHERE faction = %i )
UNION
(SELECT Name, Last Seen FROM accounts WHERE id = {what i have to put here? if i already select id in the first line, and is this even possible?} ORDER BY Last Seen)
If you don't understand something, please ask. I need this solved as fast as possible


Re: Hard query, MySQL knowers look here. - cessil - 14.07.2011

check this, it should cover what you're asking for
http://www.techrepublic.com/article/...tables/1050307


Re: Hard query, MySQL knowers look here. - WooTFTW - 14.07.2011

Quote:
Originally Posted by cessil
Посмотреть сообщение
check this, it should cover what you're asking for
http://www.techrepublic.com/article/...tables/1050307
Thanks, i got this far using subquery

pawn Код:
SELECT accounts.Name, accounts.Last Seen, characters.playerrank WHERE id = (SELECT id FROM characters WHERE faction = %i);
Is this going to work?


Re: Hard query, MySQL knowers look here. - WooTFTW - 14.07.2011

Alright thanks ******, SQL is an language, MySQL is managment system.

I don't think you understood what i need here.

Tested, didn't work.

edit: i will study JOIN a bit more.
Do you mind giving an example, according to the tables and columns i pasted above?
My english skills are not the best, so i don't understand the arcticle exactly like you.