I want to create a table that stores doctors. My problem is how i will store the specialities of a doctor as a doctor can have more than one (aphrodisiologist,dermatologist). So far i have thougth of using varchar type and storind the values in comma separated format.
CREATE TABLE IF NOT EXISTS `doctors` (
`doctor_id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(50) NOT NULL,
`password` varchar(30) NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`speciality` varchar(254) NOT NULL,
`lat` decimal(10,8) NOT NULL,
`lng` decimal(10,8) NOT NULL,
`phone` char(10) NOT NULL,
`mobile` char(10) NOT NULL,
PRIMARY KEY (`doctor_id`)
);
But my problem is when quering the table. If i want to find the doctors that have the speciality 'alfa' and i do this
select * from doctors where speciality='alfa'
the doctor that has two specialities (alfa,beta) will not be included in the result. The only thing i have thought is to use LIKE instead of WHERE but i think that there must be a better way. What is the best way to implement this (perhaps a different data type from varchar)?