내가이 쿼리가 더 많은 결과를 제공합니다. 3 행을 주석으로 달아서 더 많은 결과를 얻었을 때 나는 여전히 6 점만을 얻었습니까? 내가 여기서 뭔가를 놓친 거지 같은 나는왼쪽 조인
미국에게 ... 기분이
mysql> describe states;
+------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+----------------+
| state_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| country_id | tinyint(3) unsigned | YES | | NULL | |
| state_name | char(15) | YES | | NULL | |
+------------+---------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
세계 도시
mysql> describe world_cities;
+-------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+----------------+
| city_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| state_id | int(11) | YES | | 0 | |
| country_id | tinyint(3) unsigned | YES | MUL | NULL | |
| country | char(2) | YES | | NULL | |
| city | char(60) | YES | MUL | NULL | |
| accent_city | char(60) | YES | | NULL | |
| region | int(11) | YES | | NULL | |
| population | int(11) | YES | | NULL | |
| latitude | decimal(9,6) | YES | | NULL | |
| longitude | decimal(9,6) | YES | | NULL | |
+-------------+---------------------+------+-----+---------+----------------+
9 rows in set (0.01 sec)
편집 지금이 실행, 그것은 업데이트 한
STATE_ID world_cities 테이블에서 꽤 잘.
update world_cities wc
left join zipcodes z on wc.city = z.city
left join cities c on z.state = c.city_name
left join states s on z.state = s.state_name
set wc.state_id = s.state_id
where wc.country_id = 236
and abs(round(z.lat, 2) - round(wc.latitude, 2)) between 0 and 1
and abs(round(z.log, 2) - round(wc.longitude, 2)) between 0 and 1;
여전히 동일한 결과가 표시됩니다. –
'country_id'의 'states' 테이블에 가입 하시겠습니까? 'state_id'가 아니겠습니까? – bernie
world_cities에는 state_id가 없으므로 세계의 모든 도시가 있습니다. –