I have a problem with this query:
select start, end, surname, name, id from employee, absences where surname LIKE '$surname%' and name LIKE '$name%' and start LIKE '$start%' and name LIKE '$end%' order by start ASC
I am aware that this is not a good way to search. I tried to use a JOIN for this, but I failed. I have two tables: absences and employee, simply connected by a FK, which gives me too many results(multiplied).
How do I use a join for this? Or is there another solution?
Tables_
CREATE TABLE IF NOT EXISTS `absences` (
`absences_ID` int(11) NOT NULL,
`employee_FK` int(11) NOT NULL,
`start` date NOT NULL,
`end` date NOT NULL,
`approved` tinyint(1) NOT NULL DEFAULT '0',
`approved_date` date DEFAULT NULL,
`comment` varchar(100) NOT NULL,
`type_FK` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1371 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `employee` (
`employee_ID` int(11) NOT NULL,
`id` int(11) NOT NULL,
`name` varchar(30) DEFAULT NULL,
`surname` varchar(30) DEFAULT NULL,
`password` varchar(60) NOT NULL,
`email` varchar(255) NOT NULL,
`on_off_FK` int(11) NOT NULL,
`inactive` tinyint(1) NOT NULL DEFAULT '1',
`admin` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;