在 MYSQL 中应用双重条件

Applying dual conditions in case when in MYSQL

(问题已编辑)我的 table 有 id,status,date,sequence

情况:获取满足的ids:

我在 dbVisulizer 中写 MYSQL

编辑:尝试查询:

select id, max(date), max(sequence) from 
table
where
table.date<=now() and status='A'
order by date desc,sequence desc

听起来我只是在问直接问题而没有自己尝试任何事情,但是对于这种情况我完全被卡住了,我尝试了 case when 但无法真正取得任何好处, 任何起点都会被应用。

select id from 
table
where
table.date<now() and table.status='A'
order by date desc,sequence desc
limit 1;

请自行检查是否有错误

select id, max(date), max(sequence) from 
table
where
table.date<=now() and status='A'
order by date desc,sequence desc
group_by id;

这应该会给你想要的结果。将 table 和字段名称调整为您的 table 和字段。