date_sub(date,interval expr unit)
注釋:
date(日期字段,某一日期時間例如:2020-01-02,curdate())
interval(關鍵字,無需修改)
expr(某一數值,配合unit進行使用)
unit(單位,常用單位有:year,month,day)
使用例項:
select date_sub(curdate(),interval 1 year)
date_add(date,interval expr unit)
注釋:
date(日期字段,某一日期時間例如:2020-01-02,curdate())
interval(關鍵字,無需修改)
expr(某一數值,配合unit進行使用)
unit(單位,常用單位有:year,month,day)
使用例項:
select date_add(curdate(),interval 1 year)
mysql 常用sql語句整理
sql語言共分為四大類 資料查詢語言dql,資料操縱語言dml,資料定義語言ddl,資料控制語言dcl create database user show tables 顯示所有表 drop table t xx 刪除表 desc t xx 檢視表結構 select from tablename l...
mysql常用sql語句整理
1.replace函式 比如你要將表 tb1裡面的 f1欄位的abc替換為def update tb1 set f1 replace f1,abc def replace str,from str,to str 在字串 str 中所有出現的字串 from str 均被 to str替換,然後返回這個...
常用sql語句整理
a 判斷資料庫是否存在 if exists select from sys.databases where name 庫名 刪除資料庫 drop database 庫名b 判斷要建立的表名是否存在 if exists select from dbo.sysobjects where id objec...