Reputation: 11
How to use the SET
datatype in MySQL? I have a table Train
in which there are fields
trainno int
Weekdays set data type
Stops set data type
train name
How to write a select query where I can compare the Stops
set with a particular value like 'Mumbai'
?
Upvotes: 1
Views: 137
Reputation: 1858
Create a table like:
CREATE TABLE cl_db.Train
(
trainno INT PRIMARY KEY AUTO_INCREMENT,
Stops set('aaa','bbb','ccc') NOT NULL
)
and you can query it like
select * from cl_db.Train where Stops like 'bbb'
or like
select * from cl_db.Train where FIND_IN_SET('bbb',Stops)>0;
Upvotes: 1