如何在where条件中使用子查询?

时间:2019-10-17 12:11:34

标签: sql oracle

我只想更新行,这给了我选择的余地。这怎么可能?

UPDATE user.table1 
  SET column = 'N'
where (
  select count( * ) number, colum1, clolum2 
  from user.table1
  group by colum1, clolum2 
  having count(*) = 1
);

2 个答案:

答案 0 :(得分:0)

查询的结构如下:

`UPDATE user.table1 a
SET a.column =(SELECT COUNT(1)
              FROM table_name  b
              WHERE a.id=b.id
              AND a.mytype=b.mytype
         )
WHERE EXISTS( ....)`

答案 1 :(得分:-1)

WHERE声明不完整。

示例: .... WHERE name ='tispokes';

您可以使用子查询afaik和iirc代替 tispokes

也适用:

... WHERE EXISTS (*your subquery*);