现在有一个表ith_region存放了国家 省市 地区
原来的数据库里面有国家county 省市province 地区city三张表
现在在ith_region表里面已经有国家跟省市了,要把city的信息插入到ith_region表里 对应好省市
现在能查出city的信息只有编号跟名字,但是在ith_region表里还有其他字段已知
在写insert 语句的时候
insert into ith_region (region_id,region_name)
select MMCBA22_CityCode,MMCBA22_CityName from MMCBA22_CITY where MMCBA22_ProvinceCode = 320000,
还有city表里面查询不出来的字段(字段值已知)
如parent_id(31W5157Ei5qpGqv),region_type(2)要一起加进去
求助insert 语句怎么写

解决方案 »

  1.   

    insert into ith_region (region_id,region_name,其他字段1,其他字段2)
    select MMCBA22_CityCode,MMCBA22_CityName
    ,b表其他字段1,b表其他字段2 
    from MMCBA22_CITY ,b表where MMCBA22_CITY.关联字段=b表.关联字段
    MMCBA22_ProvinceCode = 320000,
      

  2.   

    其他字段也都在ith_region表里面,只不过原来省市的region_id现在变成了parent_id,
    以前的region_type值为1现在要插入2
    等等情况 所以不能光靠查询表来插入
      

  3.   

    select MMCBA22_CityCode,MMCBA22_CityName,parent_id from MMCBA22_CITY where MMCBA22_CITY.MMCBA22_ProvinceCode = 320000
    不能给红色字段赋值吗
      

  4.   

    select MMCBA22_CityCode,MMCBA22_CityName,parent_id from MMCBA22_CITY where  MMCBA22_CITY.MMCBA22_ProvinceCode = 320000
    怎么赋值?你想这样?
    select MMCBA22_CityCode,MMCBA22_CityName,'2' as parent_id from MMCBA22_CITY where  MMCBA22_CITY.MMCBA22_ProvinceCode = 320000
      

  5.   

    http://www.newsmth.net/pc/pccon.php?id=1585&nid=128232