I'm having a table called users
, it has a column of datatype enum. I would like to search in enum
in the SELECT
query
Table Structure:
CREATE TABLE `users` (
`id` binary(16) NOT NULL PRIMARY KEY,
`name` varchar(100) NOT NULL,
`type` enum('A','B','C','D','E','F') NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Sample Data:
INSERT INTO `cm_contact` (`id`, `name`, `type`) VALUES
(0x0b0b10bf94e511e9a32efa163e49d265, 'John', 'A,C,E'),
(0x0fd283a494b111e9a32efa163e49d265, 'Ellen', 'E,F'),
(0x25c77b6294e111e9a32efa163e49d265, 'Emma', 'B,C,D');
I need to filter the record, that who are all under the type B
and C
, that means it will return the user John
and Emma
I tried the following approach but I failed
SET @search='B,C';
SELCT * FROM users WHERE type IN @search
Kindly assist me how to achieve this.