Jump to content

HElp on this query


claudiofranck

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/50868-help-on-this-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.