Mysql version 5.0.37
Table:
'refsub', 'CREATE TABLE `refsub` (
`PROJET` char(10) NOT NULL,
`SUBSECTO` char(10) NOT NULL,
UNIQUE KEY `K_REFSUB` (`PROJET`,`SUBSECTO`),
KEY `PROJET` (`PROJET`),
KEY `SUBSECTO` (`SUBSECTO`),
CONSTRAINT `FK_REFSUB_REFCHIF` FOREIGN KEY (`PROJET`) REFERENCES `refchif` (`PROJET`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_REFSUB_SUBSECTO` FOREIGN KEY (`SUBSECTO`) REFERENCES `subsecto` (`SUBSECTO`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8'
This a table that basicaly links a project number with the sector it is invlved with so I only store the primary keys of each, a project can have multiple sectors and of course a sector can belong to multple projects.
What I need to do is basically get projects numbers that have 2 or more of the sectors, i.e. prject 1234 had electric and mechanic sectors, project 4567 had also electric and mechanic and maybe others I want to search all projects that have mechanic and electric sectors
SELECT * FROM refsub where subsecto like 'electric' and subsecto like 'mechanic';
This query returns no results, using 'or' works, 'and' get's me nothing.
Any ideas?
Thank you very much