時間, 字符, 數字 , 大於 小於,

總表結果:

1. 日期  date 和字符 匹配

SELECT * FROM `tabname`  where  `birthday`>= str_to_date('2013-09-02', '%Y-%m-%d') 
AND `birthday` <= str_to_date('2013-09-07', '%Y-%m-%d')
;

SELECT * FROM `tabname`  where  `birthday`>='2013-09-02' 
AND `birthday` <='2013-09-07';

SELECT * FROM `tabname`  where  `birthday`='2013-09-02' ;

上面  1結果和2結果相同   ,3能搜索出sql

 

2 datetime 日期時間  和字符   匹配

SELECT * FROM `tabname`  where  `starttime`>= str_to_date('2017-03-02', '%Y-%m-%d') 
AND `starttime` <= str_to_date('2017-03-07', '%Y-%m-%d')
;

SELECT * FROM `tabname`  where  `starttime`>='2017-03-02' 
AND `starttime` <='2017-03-07';

SELECT * FROM `tabname`  where  `starttime`='2017-03-02' ;
SELECT * FROM `tabname`  where  `starttime`='2017-03-07 17:32:23' ;

  結果1  和 結果2 相同   可是丟棄了  2017-03-07的數據 spa

結果3 ,沒有數據, 結果4有一條code

 

3. 字符   數字 匹配

總結:      字符比大小, 直接用  where   mychar >='1' ANd  mychar <='6';  class

才能篩選出 , 開頭在1到6之間的數字, '21' 也是小於'6' ,只匹配第一位date

SELECT * FROM `tabname`  where  mychar <='b'; -- 1
SELECT * FROM `tabname`  where  mychar >='b'; -- 2



SELECT * FROM `tabname`  where  mychar >='6';  -- 3
SELECT * FROM `tabname`  where  mychar <='6'; -- 4


SELECT * FROM `tabname`  where  mychar >=6;  -- 5
SELECT * FROM `tabname`  where  mychar <=6;	 -- 6

SELECT * FROM `tabname`  where  mychar >='6';  -- 3
SELECT * FROM `tabname`  where  mychar <='6'; -- 4搜索

SELECT * FROM `tabname`  where  mychar >=6;  -- 5
SELECT * FROM `tabname`  where  mychar <=6;     -- 6im

 完結!總結

相關文章
相關標籤/搜索