在MySql中常用的幾種查詢:
一、根據條件按字段分組查詢,條數大於1的所有數據列表:
select a.type,count(1) as sum from user a where a.type >2 group by a.type having sum >2
查詢出來的結果如下所示:
二、數據庫中表時間字段與字符串:
select * from user where unix_timestamp(created_time) > unix_timestamp('2016-08-16 00:00:01');
使用unix_timestamp函數對時間字符串進行轉義,然後再進行判斷!
具體可參考:http://timerbin.iteye.com/admin/blogs/2037840