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
)