我有一个包含id,created,user_id的表。
我想知道是否有一个查询会返回在上周内创建了多个已创建的多个唯一user_id。我开始时:
$query = "SELECT distinct user_id FROM task where created >= '" . date("Y-m-d", strtotime("-1 week", strtotime($date))) . " 00:00:00' and created <= '" . $date . " 23:59:99'"
这适用于返回所有不同的结果,但我只需要抓住上周有超过1个条目的那些。
谢谢!
答案 0 :(得分:0)
SELECT user_id FROM task
where created >= '" . date("Y-m-d", strtotime("-1 week", strtotime($date))) . " 00:00:00'
and created <= '" . $date . " 23:59:99'
group by user_id
having count(*) > 1