simplyi Posted January 15, 2010 Share Posted January 15, 2010 Please advise me a sample query or good tutoral to read about selecting distinct values from multimple tables. I have tree tables A,B,C all linked by id. table B has id of A table C has id of B If I run a query select a.name, b.address, c. phone then from a,b,c order by a.id then I get a selection form all three tables but I NEED a.NAME to be distinct. Please advise..... Thank you Quote Link to comment https://forums.phpfreaks.com/topic/188591-select-distinct-values-from-multiple-tables/ Share on other sites More sharing options...
dreamwest Posted January 16, 2010 Share Posted January 16, 2010 Grouping is important when select * distinct $res = mysql_query( "SELECT distinct * FROM table_a as a, table_b as b, table_c as group by a.name ORDER BY a.id ASC"); Otherwise try this assumed method: $res = mysql_query( "SELECT distinct name FROM table_a as a, table_b as b, table_c as group by a.name ORDER BY a.id ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/188591-select-distinct-values-from-multiple-tables/#findComment-995926 Share on other sites More sharing options...
fenway Posted January 16, 2010 Share Posted January 16, 2010 Huh? Quote Link to comment https://forums.phpfreaks.com/topic/188591-select-distinct-values-from-multiple-tables/#findComment-996192 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.