d********d 发帖数: 9639 | 1 update TABLEA set ColA = 'Y' where ColB in
(SELECT BB from TABLEB
UNION
SELECT CC from TABLEC)
为什么我一直得到error
Incorrect syntax near the keyword 'UNION'? |
i****a 发帖数: 36252 | 2 what do you get when you run this
SELECT BB from TABLEB
UNION
SELECT CC from TABLEC
【在 d********d 的大作中提到】 : update TABLEA set ColA = 'Y' where ColB in : (SELECT BB from TABLEB : UNION : SELECT CC from TABLEC) : 为什么我一直得到error : Incorrect syntax near the keyword 'UNION'?
|
d********d 发帖数: 9639 | 3 that gives correct data. the union of two tables, for the BB or CC column
【在 i****a 的大作中提到】 : what do you get when you run this : SELECT BB from TABLEB : UNION : SELECT CC from TABLEC
|
g***l 发帖数: 18555 | |
s***o 发帖数: 2191 | 5 少了个FROM吧?
update...set...from...where...
【在 d********d 的大作中提到】 : update TABLEA set ColA = 'Y' where ColB in : (SELECT BB from TABLEB : UNION : SELECT CC from TABLEC) : 为什么我一直得到error : Incorrect syntax near the keyword 'UNION'?
|
g***l 发帖数: 18555 | 6 换成CTE吧,保险, 而且两个表的COLUMN NAME也不一定一样
;with cte_temp(
SELECT BB as field_name from TABLEB
UNION ALL
SELECT CC as field_name from TABLEC
)
update TABLEA set ColA = 'Y'
from
TABLEA t, cte_temp c
where
t.colB =c.field_name |
B*****g 发帖数: 34098 | 7 what db?
which version?
【在 d********d 的大作中提到】 : update TABLEA set ColA = 'Y' where ColB in : (SELECT BB from TABLEB : UNION : SELECT CC from TABLEC) : 为什么我一直得到error : Incorrect syntax near the keyword 'UNION'?
|
s****y 发帖数: 581 | 8 co-ask
【在 B*****g 的大作中提到】 : what db? : which version?
|
a***y 发帖数: 2803 | 9 不具体的表和语句贴出来才能分析.
【在 d********d 的大作中提到】 : update TABLEA set ColA = 'Y' where ColB in : (SELECT BB from TABLEB : UNION : SELECT CC from TABLEC) : 为什么我一直得到error : Incorrect syntax near the keyword 'UNION'?
|
k*******z 发帖数: 2368 | |