如何在mysql的表中的欄位中刪除內容中包含的指定字串

2021-04-28 15:11:51 字數 972 閱讀 8028

1樓:陽光上的橋

update 表名

來 set 欄位

自名bai=concat(left(欄位名

du,instr(欄位名zhi,'[')-1),right(欄位名,length(欄位名)-instr(欄位名,']')))

where instr(欄位名,'[')>0 and instr(欄位名,']')>instr(欄位名,'[')

看得dao懂吧:

instr(欄位名,'[')表示欄位裡面[的位置,條件部分是必須有[,而且]的位置在[之後

替換的表示式是用left和right取出[之前和]之後的內容,然後用concat函連線起來

2樓:匿名使用者

在mysql中使用 update 語句配合 replace() 函式可以將表中指定欄位中的指定字串進行專刪除例:將表 table 中的 column 欄位中包含的 aa 字串刪屬除,可以使用下面語句

update talbe set column = replace(column,'aa','')

mysql 如何查詢一個欄位中的資料是否包含於字串中?

3樓:陽光上的橋

myid是什麼型別bai,是數值類

du型應這樣zhi寫:dao

select * from table where saleid=2376 and myid in (2,3,4,5,6)

如果myid是字元型別,應版該這權

樣寫:select * from table where saleid=2376 and myid in ('2','3','4','5','6')

4樓:匿名使用者

select * from table where saleid=2376 and myid in ('2','3','4','5','6')

in裡面得分著寫

mysql查詢表中是否有某個欄位

information schema.columns這表bai儲存了所 du有欄位資訊 zhiselect count from information schema.columnswhere table schema world and table name city and column nam...

mysql怎麼查欄位跟他的值在哪幾個表中出現過

利用mysql中的 的聚合函式 count 可以實現這個功能,例如需要查詢data表中name出現次數最多的記錄,可以先按照group by name分組,用count算出分組裡的條數,再按照count排序 select name,count from data group by name orde...

mysql修改欄位內容,mysql資料庫中sql修改欄位型別要怎麼做?

update banji set num 要改的值 update 表名稱 set 列名稱 新值 where 列名稱 某值 如果要改全部,就忽略條件.mysql資料庫中sql修改欄位型別要怎麼做?方法如下 復 修改一個字制 段的型別 alter table user modify new1 varch...