Jump to content

Order by column from different table?


Djrikidk

Recommended Posts

I'm not sure if this is actually supposed to be in some sort of a SQL forum instead, but since i don't know any and it is very close to PHP i'll just write it here.

 

I wanna know how i can order by a column from another table, because i have two tables, and my PHP code is meant to show users from Table 1, which is used to store login information and such, but it should Order the values by a column from a different table, Table 2, which stores the amount of money and strength the users got. Every user has a row in both tables, with a column with their Username in it.

Link to comment
https://forums.phpfreaks.com/topic/205429-order-by-column-from-different-table/
Share on other sites

What are you trying to order it by then and why?

 

You should just order it by the key you use to link the tables... otherwise when you get the data from the table via php then you can use php to order it whatever manner you want I suppose.

What are you trying to order it by then and why?

 

You should just order it by the key you use to link the tables... otherwise when you get the data from the table via php then you can use php to order it whatever manner you want I suppose.

I have the two tables, Table 1 and Table 2, my PHP code displays data from every row of Table 1, the data displayed is currently ordered by a column from Table 1, but i want it to be ordered by a column from Table 2, where it is the same rows except that in Table 2 it displays player stats like money, strength and such. So i would like that when the values from Table 1 is echoed out, they're sorted by a the strength column which is in Table 2.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.