Jump to content

select distinct values from multiple tables


simplyi

Recommended Posts

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

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"); 

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.