0
我有數據庫結構是怎樣的圖像下方在MySQL連接3個表來選擇字段
我想選擇所有的街道,與街道名稱,城市名稱,省名。我的代碼是這樣的:
SELECT province.name as province, city.name as city, subdistrict.name as subdistrict
from provinces province, cities city, subdistricts subdistrict
WHERE province.id = city.id AND city.id = subdistrict.id;
,但我只得到儘可能多的總省份的數據並非所有的街道數據
'SELECT province.name AS省, city.name AS城市, subdistrict.name AS街道 從省省 INNER JOIN城市城市 ON province.id = city.province_id INNER JOIN街道街道 ON城市.id = subdistrict.city_id;'這是正確的 –