0
Location table
-----------------------------------------------
|location.id|country.id|state.id|city.id|

Country
-----------------------------------------------
|country.id|country|

State
-----------------------------------------------
|state.id|state|

City
-----------------------------------------------
|city.id|city|

これで、location.id ができました。location.id から国、都市、州の名前を一度に取得する必要があります。

これを解決するには、SQL クエリのヘルプが必要です

4

2 に答える 2

1

これはテストされていませんが、このようなことを試して、内部結合を調べてください。

select * from locations
inner join Country on `Country`.`country.id` = locations.`country.id`
inner join State on `State`.`state.id` = locations.`state.id`
inner join City on `City`.`city.id` = locations.`city.id`
于 2013-07-19T19:27:37.667 に答える
0
SELECT location.id, city.city, state.state,country.country
FROM location,city,state,country
WHERE location.country_id = country.id
AND location.city_id = city.id
AND location.state_id = state.id
于 2013-07-19T19:29:15.273 に答える