Mysql 擷取目前時間的前幾天和欄位中的時間進行比較,mysql目前時間

來源:互聯網
上載者:User

Mysql 擷取目前時間的前幾天和欄位中的時間進行比較,mysql目前時間
 DELETE FROM zhongqiu WHERE caretatime<=ADDDATE(NOW(),-14) 


caretatime欄位為時間欄位
`caretatime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,



-14為14天以前
mysql中怎查詢時間與當天的日期相等,也就是說資料庫中的時間欄位與日期格式不一樣怎比較查詢

select * from tbname where date_format(tbname.colstime,'%Y-%m-%d')=now()
 
MYSQL 裡面怎從某表裡面取出欄位,為(目前時間)小於(該表內時間欄位)?

有問題的,你now()取出的字串類型的,順便問下你定義的欄位是什麼類型的,字串怎麼可能用四則符號來描述- -#

估計你放的不是時間戳記類型的,取條數是吧=》這樣寫吧:
select count(state) from A where unix_timestamp(endtime) >current_timestamp() ;
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.