mst_AirPort表AirPortID (UNIQUEIDENTIFIER)AirPortCode
111111111111111111111 LAX
111111111111111111112 PVG
111111111111111111113 TPE
3111111111111111111113 SGN
3111111111111111111114 SAN就是根据'lax,pvg,tpe' 字符串,取mst_AirPort表的三个AirPortID ,再插入到AirPortGroup表中
INSERT INTO AirPortGroup(AirPortID,X)
VALUES ( AirPortID , x)
谢谢!
111111111111111111111 LAX
111111111111111111112 PVG
111111111111111111113 TPE
3111111111111111111113 SGN
3111111111111111111114 SAN就是根据'lax,pvg,tpe' 字符串,取mst_AirPort表的三个AirPortID ,再插入到AirPortGroup表中
INSERT INTO AirPortGroup(AirPortID,X)
VALUES ( AirPortID , x)
谢谢!
解决方案 »
- 三个表如何full join(sql语句有点长...)
- 部分更新语句怎么写!
- 求求高手们,给我个活下去理由啊,为什么这样不行呢?
- 数据库的第三范示具体是在第二范示加了什么条件,能举个通俗易懂的例子就好了。
- sql2005导入使用bulk insert
- 利用SQL等数据库软件为某公司或某网站设计一个后台数据库
- 简单问题
- 这个sql怎么写,在线等待。
- 一直困扰我的一个基本的有关SYBASE的问题: 访问SYBASE服务器,是否一定要安装客户端软件,在哪里可以下载,其名称叫什么?
- 分班问题,一个富有挑战的话题!
- 请帮忙看看触发器为什么不触发?
- SQL Server安装问题 急啊```````````````````````````````````````
select AirPortID , x from mst_airport where airportcode in('lax','pvg','tpe' )
给分是种回报!
欢迎光临:www.sodeer.com
_______________________________
不行的
To,
sdhylj(青锋--SS) 'lax,pvg,tpe' 这个字符串是动态得到的,我不能拆开加‘’啊,有其它的办法吗
INSERT INTO AirPortGroup(AirPortID,X)
select AirPortID , x from mst_airport where airportcode in(replace('''lax,pvg,tpe''',',',''','''));
或
INSERT INTO AirPortGroup(AirPortID,X)
select AirPortID , x from mst_airport where airportcode in(replace('lax,pvg,tpe',',',''','''))
sdhylj(青锋--SS)不行啊,总不见得用游标吧。这样很损伤资源的。谢谢!
set @s = 'lax,pvg,tpe'INSERT INTO AirPortGroup(AirPortID,X)
select AirPortID , x from mst_airport where airportcode in(replace(@s, ',' , ''','''));
set @val='lax,pvg,tpe';
set @sql='INSERT INTO AirPortGroup(AirPortID,X) select AirPortID , x from mst_airport where airportcode in('''+replace(@val,',',''',''')+''')';
exec(@sql);
DECLARE @AirGrouplD UNIQUEIDENTIFIER
SET @FGW = 'lax,pvg,tpe,sgn'
SET @FGW = ISNULL( @FGW,'')+ ','
WHILE CHARINDEX(',',@FGW) >0
BEGIN SELECT @AirGrouplD = AirPortID FROM MST_AirPort WHERE AirPortCode = LEFT (@FGW ,CHARINDEX(',',@FGW)-1)
print convert(nvarchar(100),@AirGrouplD) +''
IF @AirGrouplD IS NOT NULL
INSERT INTO AirPortGroup(AirPortGroupID, AirPortGroupName)
VALUES (@AirGrouplD, @FGW)
SET @FGW =STUFF (@FGW,1 , CHARINDEX(',',@FGW),'')
END
sdhylj(青锋--SS)不行的。看似简单的方法,可能我门没有找到好的方法,不过谢谢大家了。