首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

求一条快速更新SQL语句解决方案

2012-09-11 
求一条快速更新SQL语句地区表SQL codeCREATE TABLE `ecs_region` (`region_id` smallint(5) unsigned NOT

求一条快速更新SQL语句
地区表

SQL code
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_id1                0                中国         0                02                1                北京         1                03                1                安徽         1                04                1                福建         1                05                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=MyISAMconsignee          country         province        city           district 收货人               0              1               2             XX地址 用select语句查找ecs_order_info的时候,如何让查询的结果显示中文的收货人省市区?新建个列也行。能快速就好


[解决办法]
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

热点排行