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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.