mysql語句

去掉換行符和回車符

UPDATE table SET field = REPLACE(REPLACE(field , CHAR(10), ‘’), CHAR(13), ‘’);

ids修改爲32位隨機字符

update table set ids = replace(UUID(), ‘-’, ‘’) where length(ids) < 32

關聯修改時,若爲空,則不修改

update account a set a.person_id = IFNULL((select b.ids from person b where a.person_id = b.ids ), a.person_id )

將查詢到的一列數據合併成字符串

select a.id 序號, a.name 姓名, GROUP_CONCAT(b.account separator ‘;’) 賬號
from person a, account b
where 1 = 1
and a.ids = b.person_id
GROUP BY a.ids;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章