select * from(
select 1 col1,'123' col2 union all
select 2 col1,'A-BC' col2 union all
select 3 col1,'AAA*BBB' col2 union all
select 4 col1,'ab%c' col2
) t
where col2 like '%[^a-z,^A-Z,^0-9,^.,^*,^_,^-]%'
例如:
select * from
(
select 1 col1,'123' col2 union all
select 2 col1,'A-BC' col2 union all
select 3 col1,'AAA*BBB' col2 union all
select 4 col1,'ab%c' col2
) t
where col2 like '%[^a-z,^A-Z,^0-9,^_,^-,^.,^*]%'
上面第2、4条记录都会出来,下面的则只会出来第4条记录:
select * from
(
select 1 col1,'123' col2 union all
select 2 col1,'A-BC' col2 union all
select 3 col1,'AAA*BBB' col2 union all
select 4 col1,'ab%c' col2
) t
where replace(col2,'-','') like '%[^a-z,^A-Z,^0-9,^_,^-,^.,^*]%'