select * from tt where find_in_set('222','222,123,44,546')>0 or 用INSTR
if find_in_set('222','222,123,44,546')>0 then 你的操作 end ifFIND_IN_SET(str,strlist) Returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by ‘,’ characters. If the first argument is a constant string and the second is a column of type SET, the FIND_IN_SET() function is optimized to use bit arithmetic. Returns 0 if str is not in strlist or if strlist is the empty string. Returns NULL if either argument is NULL. This function does not work properly if the first argument contains a comma (‘,’) character. mysql> SELECT FIND_IN_SET('b','a,b,c,d'); -> 2
if find_in_set('222',new.tt)>0 then set new.tt=concat(new.tt,'222'); end iftt是你的字段名称。
这种情况应该使用find_in_set触发器中做如下操作。if find_in_set('222',new.columnName)=0 then set new.columnName=concat(new.columnName,',222'); end if
or
用INSTR
你的操作
end ifFIND_IN_SET(str,strlist) Returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by ‘,’ characters. If the first argument is a constant string and the second is a column of type SET, the FIND_IN_SET() function is optimized to use bit arithmetic. Returns 0 if str is not in strlist or if strlist is the empty string. Returns NULL if either argument is NULL. This function does not work properly if the first argument contains a comma (‘,’) character. mysql> SELECT FIND_IN_SET('b','a,b,c,d');
-> 2
if find_in_set('222',new.tt)>0 then
set new.tt=concat(new.tt,'222');
end iftt是你的字段名称。
set new.columnName=concat(new.columnName,',222');
end if