Page 1 of 1

Hardest Yet

Posted: Sun Sep 15, 2013 3:44 pm
by Epiales
:lol: :lol: :lol:

I didn't know where to put this, but the below took me forever to come up with LOL... The life of coding YAY

Code: Select all

$get_users = mysql_query("SELECT ranking.id as id, score, stats.attack, stats.defense, overall FROM ranking INNER JOIN stats ON ranking.id = stats.id WHERE overall>'0' ORDER BY overall ASC") or die(mysql_error());
while($row = mysql_fetch_assoc($get_users)){

Probably the hardest query of me life lol!

Re: Hardest Yet

Posted: Sun Sep 15, 2013 6:59 pm
by vitinho444
I never tried using Inner join, what does it do (sorry for offtopic)

PS: was this post a question?

Re: Hardest Yet

Posted: Sun Sep 15, 2013 7:11 pm
by Epiales
vitinho444 wrote:I never tried using Inner join, what does it do (sorry for offtopic)

PS: was this post a question?
Naw, wasn't a question... I didn't know really where to put this topic lol.... It basically allows you to call fields from two different tables in a query. And if both tables have the same id or name, then you can join them together to use them. Like in my user table, I have my usernames, but no other place do I show usernames. So I sometimes have to inner join the username with like the stats table, that holds all the player stats information. It really comes in handy.

Since all my information on the player is basically in the stats table, when I run a battle scenario, I can't just call from the stats table to get the username; I have to call from the user table to get the username. So joining stats and user tables together makes it much easier to handle the query.

The best way I know how to explain it :lol: Hope it was understandable!

Re: Hardest Yet

Posted: Sun Sep 15, 2013 8:26 pm
by Jackolantern
Very nice! Joins are critical to master for RDBMS. I have recently come to love NoSQL databases like MongoDB, but of course they aren't right for every situation (one such example is if you need to compare all kinds of data, such as in business intelligence software).

Re: Hardest Yet

Posted: Sun Sep 15, 2013 9:06 pm
by vitinho444
Yap i got it thanks :)