insert into 替換成你的表名 (name,date,value) values ('魂牽夢縈','2009-06-08 23:53:17','朝秦暮楚');
目前創(chuàng)新互聯(lián)已為上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管、網(wǎng)站托管、服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計、安次網(wǎng)站維護等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
如果你是直接在Mysql中操作的話,建議你用下navcait for mysql,他界面操作完成后有一個查看代碼,這樣你既可以達到想要的功能,有能很快學(xué)到不懂的sql語句
MySQL數(shù)據(jù)庫中year()函數(shù)是求某個特定日期中的年份,代碼如下:
select '2015-08-11' as date,year('2015-08-11') as year;
確定一個日期是一年中的第幾個季度,可以用QUARTER()函數(shù)實現(xiàn),代碼如下:
SELECT '2015-08-11' AS DATE,QUARTER('2015-08-11') AS QUARTER;
返回一個日期是一年中的月份,利用month()函數(shù)實現(xiàn),代碼如下:
SELECT '2015-08-11' AS DATE,MONTH('2015-08-11') AS MONTH;
獲取一個確定日期是一個月份中的多少號,可以用day()函數(shù)求得,具體實現(xiàn)代碼如下:
SELECT '2015-08-11' AS DATE,DAY('2015-08-11') AS DAY;
有時日期中帶有時間,而如何獲取小時數(shù),這可以利用自帶的函數(shù)hour()實現(xiàn),代碼如下:
SELECT '2015-08-11 12:20:45' AS DATE,HOUR('2015-08-11 12:20:45') AS HOUR;
求取日期時間中的分鐘數(shù),可以利用MINUTE()函數(shù)實現(xiàn),代碼如下:
SELECT '2015-08-11 12:20:45' AS DATE,MINUTE('2015-08-11 12:20:45') AS MINUTE;
最后,獲取時間中的秒數(shù),利用SECOND()函數(shù)實現(xiàn),代碼如下:
SELECT '2015-08-11 12:20:45' AS DATE,SECOND('2015-08-11 12:20:45') AS SECOND;
做一個學(xué)校項目的時候 要根據(jù)上中晚查詢 最后用的是
date_format(t1.record_time, '%H:%i:%s')??
SELECT t2.class_name,t1.class_no,t1.course_id,t1.course_name,t1.id,t1.pic_url,t1.record_time,t1.sign_day,t1.status,t1.student_name,t1.student_no FROM t_e_sign t1 LEFT JOIN t_e_sys_org t2 ON t2.org_code = t1.class_no WHERE IF (:studentName is not null, t1.student_name LIKE CONCAT('%',:studentName,'%') , 1 = 1) and IF (:className is not null, t2.class_name LIKE CONCAT('%',:className,'%') , 1 = 1) and IF (:startTime is not null, date_format(t1.record_time, '%Y-%m-%d') =:startTime , 1 = 1) and IF (:endTime is not null, date_format(t1.record_time, '%Y-%m-%d') =:endTime , 1 = 1) and IF (:startdetailTime is not null, date_format(t1.record_time, '%H:%i:%s') =:startdetailTime , 1 = 1) and IF (:enddetailTime is not null, date_format(t1.record_time, '%H:%i:%s') =:enddetailTime , 1 = 1) ORDER BY ?#{#pageable}",?
整個語句也寫下吧