set names 'utf8mb4'; CREATE TABLE `t1` ( `id` int unsigned NOT NULL AUTO_INCREMENT , `name` varchar(100) CHARACTER SET utf8 , PRIMARY KEY (`id`), KEY `idx_name` (`name`) USING BTREE ) ENGINE=InnoDB; insert into t1(name) values ('()'); select name from t1 where name = replace(replace('()', '(', '('), ')', ')') -- cond a or name = replace(replace('()', '(', '('), ')', ')') -- cond b ;/* with one row */ select name from t1 where name = replace(replace('()', '(', '('), ')', ')') -- cond b or name = replace(replace('()', '(', '('), ')', ')') -- cond a ; /* empty set */