Demonic Posted September 29, 2006 Share Posted September 29, 2006 Can someone tell me how I could order a table by another tables Id using Join mysql syntax.Its confusing.Select * FROM table1,table2 ORDER BY table2.idIs that how I would do it? Quote Link to comment Share on other sites More sharing options...
extrovertive Posted September 29, 2006 Share Posted September 29, 2006 A simple joinSELECT * FROM table1 t1JOIN table2 t2ON t1.id = t2.id ORDER BY t2.id Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 29, 2006 Author Share Posted September 29, 2006 can you explain that? the t1 and t2 threw me off bad.(same thing happened when looking at the manual ???) Quote Link to comment Share on other sites More sharing options...
extrovertive Posted September 29, 2006 Share Posted September 29, 2006 t1 is just a short name label for table1.You can still use the original table1 name.SELECT * FROM table1 JOIN table2ON table1.id = table2.id ORDER BY table2.idsame thing.Another way to join is:SELECT * FROM table1, table2WHERE table1.id = table2.idORDER BY table2.idHowever, the first method is better since there's more things with you can do using a JOIN clause. Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 29, 2006 Author Share Posted September 29, 2006 K Thanks :) Ill try it now. (to see if it really works :O) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.