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
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
總結: 字符比大小, 直接用 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
完結!總結