需求:取表中全部数据,其中过滤掉指定字段的值
- 原生sql-where not exists:过滤h_article表中art_status = -1 and add_user_id != 1的数据,获取剩余的数据
select * from h_article a where not exists(select * from h_article b WHERE a.art_uuid = b.art_uuid and art_status = -1 and add_user_id != 1
- hyperf 框架 - whereNotExists:
$query->whereNotExists(function ($query) { // 剔除非本人存草稿箱的数据
$query->select(Db::raw(1))
->from('article as b')
->whereRaw('h_b.art_uuid = h_article.art_uuid and art_status = -1 and add_user_id != 1');
});