我的桌子:
tbl_questions =>
qid
question
detail
mcid
cid
uid
answercount
dateposted
status
showname
emailnotify
question_type_id
我想按小时分组所有行。{dateposted = Ymd H:i:s} 我想将 {question_type_id 更新为 2} 在那一小时内我有更多行。
好吧,如果有人每小时有 15 个问题,我想给他们类型 2,但只有那个小时内的那些消息(行)。对不起,很难说出我到底想要什么,我的英语很差。
sample data
tbl_questions =>
qid = 1, uid = 1, dateposted = 2013-01-01 10:11:10, question_type_id = 1
qid = 2, uid = 1, dateposted = 2013-01-01 10:16:10, question_type_id = 1
qid = 3, uid = 1, dateposted = 2013-01-01 10:18:10, question_type_id = 1
qid = 4, uid = 1, dateposted = 2013-01-01 10:19:10, question_type_id = 1
qid = 5, uid = 1, dateposted = 2013-01-01 10:20:10, question_type_id = 1
qid = 6, uid = 1, dateposted = 2013-01-01 10:22:10, question_type_id = 1
qid = 7, uid = 1, dateposted = 2013-01-01 10:23:10, question_type_id = 1
qid = 8, uid = 1, dateposted = 2013-01-01 10:24:10, question_type_id = 1
qid = 9, uid = 1, dateposted = 2013-01-01 10:25:10, question_type_id = 1
qid = 10, uid = 1, dateposted = 2013-01-01 10:26:10, question_type_id = 1
qid = 11, uid = 1, dateposted = 2013-01-01 10:27:10, question_type_id = 1
qid = 12, uid = 2, dateposted = 2013-01-01 10:17:10, question_type_id = 1
qid = 13, uid = 2, dateposted = 2013-01-01 10:27:10, question_type_id = 1
qid = 14, uid = 1, dateposted = 2013-01-01 12:27:10, question_type_id = 1
我想要update
他们,rows
因为posted by uid = 1
一小时内超过限制。我需要set question_type_id = 2
在那些行中。
所以预期的输出是: tbl_questions =>
qid = 1, uid = 1, dateposted = 2013-01-01 10:11:10, question_type_id = 2
qid = 2, uid = 1, dateposted = 2013-01-01 10:16:10, question_type_id = 2
qid = 3, uid = 1, dateposted = 2013-01-01 10:18:10, question_type_id = 2
qid = 4, uid = 1, dateposted = 2013-01-01 10:19:10, question_type_id = 2
qid = 5, uid = 1, dateposted = 2013-01-01 10:20:10, question_type_id = 2
qid = 6, uid = 1, dateposted = 2013-01-01 10:22:10, question_type_id = 2
qid = 7, uid = 1, dateposted = 2013-01-01 10:23:10, question_type_id = 2
qid = 8, uid = 1, dateposted = 2013-01-01 10:24:10, question_type_id = 2
qid = 9, uid = 1, dateposted = 2013-01-01 10:25:10, question_type_id = 2
qid = 10, uid = 1, dateposted = 2013-01-01 10:26:10, question_type_id = 2
qid = 11, uid = 1, dateposted = 2013-01-01 10:27:10, question_type_id = 2
qid = 12, uid = 2, dateposted = 2013-01-01 10:17:10, question_type_id = 1
qid = 13, uid = 2, dateposted = 2013-01-01 10:27:10, question_type_id = 1
qid = 14, uid = 1, dateposted = 2013-01-01 12:27:10, question_type_id = 1