I have 3 tables - table1, table2, table3 - all have a field called Name
table1 has 20 Names
table1 has 30 Names
table1 has 50 Names
I want all the names from all the tables in one query (100 names) :
SELECT * FROM table1,table2,table3 will return 30000 names (repeats)
and SELECT DISTINCT(t1.Name),DISTINCT(t2.Name),DISTINCT(t3.Name) FROM table1 t1, table2 t2, table3 t3 doesnt work.
What other options are there ?
Thanks
1 SQL from more than on table without foreign key
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you have to attach the tables together somehow in order to use joins correctly or you will get multiples.
maybe you should look into a [mysql_man]union[/mysql_man].. and post your queries in
maybe you should look into a [mysql_man]union[/mysql_man].. and post your queries in
Code: Select all
tags when [u]not[/u] in php code, please....