Php 关于join的mySQL更新查询

Php 关于join的mySQL更新查询,php,mysql,Php,Mysql,我有一个国家数据库和另一个名为zones的表 Countries [id, name, status (1 enabled 0 disabled) ] Zones [id, name, country_id] 我使用以下查询将所有国家与其所在区域进行匹配 select z.name as state, z.id as state_id, c.name as country_name, c.id as country_id, c.status as country_status

我有一个国家数据库和另一个名为zones的表

Countries 
[id, name, status (1 enabled 0 disabled) ]


Zones 
[id, name, country_id]
我使用以下查询将所有国家与其所在区域进行匹配

select 
z.name as state, 
z.id as state_id, 
c.name as country_name, 
c.id as country_id, 
c.status as country_status 
from countries c left join zones z on c.id = z.country_id 
基本上一个区域就是状态,输出是这样的

+-----------------------------------------------------+----------+---   -----------------------------------------+------------+----------------+
| state                                               | state_id | country_name                               | country_id | country_status     |
+-----------------------------------------------------+----------+---  -----------------------------------------+------------+----------------+
| NULL                                                |     NULL | Christmas Island                           |         45 |              1   
| NULL                                                |     NULL | Puerto Rico                                |        172 |              1    
| NULL                                                |     NULL   Isle of Man                                |        254 |              1  
| Álava                                        |     2971 | Spain                                      |        195 |              1   
| Ávila                                        |     2976 | Spain                                      |        195 |              1 
| Évora                                        |     2656 | Portugal                                   |        171 |              1   
输出是巨大的粘贴在这里,所以只显示在最后的结果


我想将没有区域的国家/地区的状态更新为0。你知道我如何通过mySQL做到这一点吗

您可以这样使用
不在
中:

 update Countries set status=0 where id not in (select distinct country_id from Zones )