I need to order rows over their column source. However, here’s the table I am querying (simplified):
+---+-------+-----+
|id |source |foo |
+---+-------+-----+
|1 |5 |hey |
|2 |7 |yo |
+---+-------+-----+
And here are the sources:
+---+-------+
|id |name |
+---+-------+
|5 |First |
|7 |Awesome|
+---+-------+
Now, if I use a query like this:
SELECT * FROM table ORDER BY source
…the results will order by the id of the source, not the actual name of it. I could simply order the results in PHP, but I’m looking for a sql-solution, if available.
Any help will be appreciated!
Sounds like you just need to join the tables together, like so:
Assuming your sources table is called sources…