优先查询条件
程序员文章站
2022-03-03 11:50:57
...
select distinct rule_id from t_tag_and_rule s
where label_id in (90004005,90007007) and (
status = 1 or label_id not in (
select label_id from t_tag_and_rule where label_id in (90004005,90007007) and status = 1
)
);
以 status=1优先,没有1的选择其它状态;