krio Posted September 11, 2009 Share Posted September 11, 2009 I'm learning mysql and have been trying to get this working, but an error always comes up no matter how I try it - or it just doesn't show anything from the table. I have 3 tables, all with the same amount of columns and name of columns I want to list all the values in alphabetical order by title Tables: General - Temp - Location Columns: id - url - title - description How would you write the select statement? I have tried numerous ways and can't figure it out... I'm guessing it would look something like SELECT * FROM General JOIN Temp ON General.title = Temp.title JOIN Location ON Temp.title = General.title I have played around extensively with changing the values like Temp.title = General.title and that doesnt seem to help Any ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/173938-solved-getting-all-values-from-three-different-tables-join-problem/ Share on other sites More sharing options...
krio Posted September 11, 2009 Author Share Posted September 11, 2009 I forgot to add the ORDER BY ASC, but I jsut want to get the select working as it is the most imporant Quote Link to comment https://forums.phpfreaks.com/topic/173938-solved-getting-all-values-from-three-different-tables-join-problem/#findComment-916910 Share on other sites More sharing options...
Mark1inLA Posted September 11, 2009 Share Posted September 11, 2009 SELECT General.id, General.url, General.title, General.description, Temp.id, Temp.url, Temp.title, Temp.description, Location.id, Location.url, Location.title, Location.description FROM General INNER JOIN Temp ON General.id = Temp.id INNER JOIN Location ON Temp.id = Location.id ORDER BY General.title Will this work? Quote Link to comment https://forums.phpfreaks.com/topic/173938-solved-getting-all-values-from-three-different-tables-join-problem/#findComment-916925 Share on other sites More sharing options...
krio Posted September 12, 2009 Author Share Posted September 12, 2009 hey thank you for the response! it is showing a result, but it is only showing items from the general board.. and it is only showing the amount of entries from the temp board... very weird! Quote Link to comment https://forums.phpfreaks.com/topic/173938-solved-getting-all-values-from-three-different-tables-join-problem/#findComment-916997 Share on other sites More sharing options...
Mark1inLA Posted September 12, 2009 Share Posted September 12, 2009 Ahh, its probably because you need to use identifiers for the other columns like Temp.id as `temp.id`. I shouldve noticed that before submitting it. Quote Link to comment https://forums.phpfreaks.com/topic/173938-solved-getting-all-values-from-three-different-tables-join-problem/#findComment-917034 Share on other sites More sharing options...
krio Posted September 12, 2009 Author Share Posted September 12, 2009 working thanks! Quote Link to comment https://forums.phpfreaks.com/topic/173938-solved-getting-all-values-from-three-different-tables-join-problem/#findComment-917044 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.