我正在尝试创建一个查询,该查询将更新table_1
列的位置id_owner
比5 rows
相同的多owner id
,它需要将列“ active
”设置为3
用户拥有的所有行。
我尝试了几种不同的方法,但每种方法都是空的。有任何想法吗?
我正在尝试创建一个查询,该查询将更新table_1
列的位置id_owner
比5 rows
相同的多owner id
,它需要将列“ active
”设置为3
用户拥有的所有行。
我尝试了几种不同的方法,但每种方法都是空的。有任何想法吗?
使用此UPDATE
查询JOIN
来实现此目的:
UPDATE table1 t1
JOIN
(
SELECT id_owner
FROM table1
GROUP BY id_owner
HAVING COUNT(*) > 5
) t2
ON t1.id_owner = t2.id_owner
SET t1.active = 3;
你可以试试这个:-
update table_1
set active = 3
where owner_id in
(
select * from
(
select owner_id
from table_1
group by owner_id
having count(*) > 5
) a
)
update table_1
set active = 3
where owner_id in
(
select * from
(
select owner_id
from table_1
group by owner_id
having count(*) > 5
) x
)