需要同一个表的所有日期中都存在的记录。 这里应该是x、y、z的记录。 请引用上面链接图像中的表结构
最佳答案
试试这个:(更新)
select name, t.date_cnt
from yourtable
join (select count(distinct `date`) as date_cnt from yourtable) t
group by name
having count(distinct `date`) = date_cnt
过去 6 天:
select name, t.date_cnt
from yourtable
join (
select count(distinct `date`) as date_cnt
from yourtable
where str_to_date(`date`, '%d-%m-%y') >= date_add(now(), interval -6 day)
) t
where str_to_date(`date`, '%d-%m-%y') >= date_add(now(), interval -6 day)
group by name
having count(distinct `date`) = date_cnt
关于mysql - 从表中获取一条记录,该记录在所有日期中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38737396/