gpt4 book ai didi

database - PostgreSQL : how to delete rows of Table1 where category = x (but Category is defined in Table 2)?

转载 作者:行者123 更新时间:2023-11-29 14:20:17 27 4
gpt4 key购买 nike

我有一个 Postgres 数据库。我正在尝试根据表 2 中表达的条件删除表 1 中的行。

表 1:id, object_id, time, action_type

表 2:object_id, object_name, object_category

我想删除表 1 中的所有行,其中 object_category = x。

最佳答案

您可以将 in 语句与 delete 一起使用:

delete from table1
where object_id in (select object_id from table2 where table2.object_category = x)

关于database - PostgreSQL : how to delete rows of Table1 where category = x (but Category is defined in Table 2)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30676192/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com