地区表CREATE TABLE `ecs_region` (
   `region_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
   `parent_id` smallint(5) unsigned NOT NULL DEFAULT '0',
   `region_name` varchar(120) NOT NULL DEFAULT '',
   `region_type` tinyint(1) NOT NULL DEFAULT '2',
   `agency_id` smallint(5) unsigned NOT NULL DEFAULT '0',
   PRIMARY KEY (`region_id`),
   KEY `parent_id` (`parent_id`),
   KEY `region_type` (`region_type`),
   KEY `agency_id` (`agency_id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8region_id parent_id region_name region_type agency_id
1             0             中国      0             0
2             1             北京      1             0
3             1             安徽      1             0
4             1             福建      1             0
5             1             甘肃      1             0
//另外一个order表CREATE TABLE `ecs_order_info` (
   
   `consignee` varchar(60) NOT NULL DEFAULT '',
   `country` smallint(5) unsigned NOT NULL DEFAULT '0',
   `province` smallint(5) unsigned NOT NULL DEFAULT '0',
   `city` smallint(5) unsigned NOT NULL DEFAULT '0',
   `district` smallint(5) unsigned NOT NULL DEFAULT '0',
 
 ) ENGINE=MyISAM
consignee          country         province        city           district
 收货人               0              1               2             XX地址 
用select语句查找ecs_order_info的时候,如何让查询的结果显示中文的收货人省市区?新建个列也行。能快速就好

解决方案 »

  1.   

    select *,
    (select region_name from ecs_region where region_id=a.country),
    (select region_name from ecs_region where region_id=a.province),
    (select region_name from ecs_region where region_id=a.city)
    from ecs_order_info a 
      

  2.   

    就是查询ecs_order_info的时候,能显示中文的省市区,效率不考虑!
      

  3.   

    consignee          country         province        city           district
     收货人               0              1               2             XX地址 
    0、1、2具体是什么?
      

  4.   

    数字代表的是地址表中的region_id谢谢各位