一条SQL语句

0 views
Skip to first unread message

goag...@gmail.com

unread,
Apr 20, 2006, 1:42:54 AM4/20/06
to goagrass
A表中结构如下

id a b c
1 xx yy zz
2 aa bb cc
3 dd ee ff
B表中结构如下

id d
1
2
3

用一条语句把表A中的a b
c三个字段以xx|yy|zz的形式存到B表,条件是Id号相同

如下:
update t2
set t2.d = rtrim(t1.a) + '|' + rtrim(t1.b) + '|' + rtrim(t1.c)
from table6 t2
Join table5 t1 on t2.id = t1.id

update table6 set d=rtrim(x.a)+'|'+rtrim(x.b)+'|'+rtrim(x.c) from
table5 x where x.id=table6.id

Reply all
Reply to author
Forward
0 new messages