SQL 隨筆記錄 插入,更新,擷取

2021-09-08 11:47:21 字數 990 閱讀 2636

-- 正數時:  擷取字串中逗號',' 第一次出現左邊的字串  

select substring_index(telephone,',', 1) as functiona from user

-- 負數時: 擷取字串中逗號',' 最後一次出現右邊的字串

select substring_index(telephone,',', -1) as functiona from user

-- telephone email

-- 去除字段右邊空格

update user set telephone =rtrim(telephone);

-- 去除字段左邊空格

update user set telephone =ltrim(telephone);

update device set rfid = substring(dev_id,13)

-- 插入多條資料

insert into user_card_bind (id)

values

(10051001),

(10051001),

(10051001),

select email from user where email is null

-- 查詢字元出現的位置 從1開始

select locate('/',telephone) from user

-- 擷取字串 不包括'/'斜槓字元 要+1

select substring(telephone,locate('/',telephone)+1) from user

-- 更新資料

update user set user_group_id = null where user_group_id = 'mull'

-- 對資料進行分組

select function_dep from user group by function_dep

SQL 插入 更新 刪除記錄語句

無需指定要插入資料的列名,只需提供被插入的值即可 insert into table name values value1,value2,value3,需要制定列名和插入的值 insert into table name column1,column2,column3,values value1,v...

Android 隨筆記錄

安卓環境變數配置 系統變數 變數名 android home 變數值 d android android sdk windows path中增加 android home platform tools android home tools 返回 override public boolean onk...

Task async await隨筆記錄

using system using system.collections.generic using system.linq using system.text using system.threading using system.threading.tasks namespace taskco...