我在fiddle中的查询如下。
select * from notification where status = 0 and ( notif_id in (select notif_id from notif_user where user_id = 1) OR notif_id in (select notif_id from notif_group where group_id = 1))
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=cad284e77218eb37461e60b6308bf85f
查询按预期工作。但是,查询是否会有任何性能问题。是否可以将内部查询转换为连接?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您的子查询不是依赖子查询,而是独立的。也就是说,它们不引用您的
notification表中的列,而只引用它们自己表中的列。所以这里没有性能问题。