Multi table query
Posted: 05.11.2011, 16:50
Hi,
I'm working on a small project but i have problems querying multiple tables.
Here are my tables:
Tb_clients
- client_id
- client_name
- client_phone
- id_city_born(tb_city)
- id_city_died(tb_city)
tb_city
- city_id
- city_name
- id_country(tb_country)
tb_country
- country_id
- country_name
Now i want to get the whole table content:
- client_name
- client_phone
- city_name/country_name(born)
- city_name/country_name(died)
I want to return those fields in one row of the grid, but unfortunately with no luck the return is in 2 rows.
I'm working on a small project but i have problems querying multiple tables.
Here are my tables:
Tb_clients
- client_id
- client_name
- client_phone
- id_city_born(tb_city)
- id_city_died(tb_city)
tb_city
- city_id
- city_name
- id_country(tb_country)
tb_country
- country_id
- country_name
Now i want to get the whole table content:
- client_name
- client_phone
- city_name/country_name(born)
- city_name/country_name(died)
I want to return those fields in one row of the grid, but unfortunately with no luck the return is in 2 rows.
Code: Select all
select * from (tb_client join tb_city on tb_client.id_city_born=tb_city.city_id or tb_client.id_city_died=tb_city.city_id) join tb_country on tb_country.country_id=tb_city.country_id