HelloI've a little Mysql query problem.I've 2 tables for a address book application.CREATE TABLE `contacts` ( `pid` int(11) NOT NULL auto_increment, `organisation` varchar(50) NOT NULL default '', `title` varchar(50) default NULL, `nom` varchar(50) default NULL, `prenom` varchar(50) default NULL, `address1` varchar(150) default NULL, `address2` varchar(150) default NULL, `npa` varchar(10) default NULL, `city` varchar(50) default NULL, `code_pays_rel` varchar(50) NOT NULL default '', `phone` varchar(25) default NULL, `fax` varchar(25) default NULL, `mobile` varchar(25) default NULL, `email` varchar(70) default NULL, `web_url` varchar(70) default NULL, `web_text` varchar(70) default NULL, `comment` blob, PRIMARY KEY (`pid`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1126 ;
And a country table with 236 entries:CREATE TABLE `pays` ( `idpays` int(11) NOT NULL auto_increment, `code_pays` varchar(50) default NULL, `pays` varchar(50) default NULL, PRIMARY KEY (`idpays`), UNIQUE KEY `code_pays` (`code_pays`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=237 ;
When I search with a keyword only in contact. No problem (simple!):SELECT *FROM contactsWHERE nom like '%SearchString%' or web_url like '%SearchString%' or organisation like '%SearchString%'ORDER BY organisation, nom ASCResult: 1 (and this is correct)
but if I add the "pays" table to add the name of the country for my contact name regarding the "code_pays_rel" field in contact table. I've 236 entries instead of 1 ;o(SELECT *FROM contacts, paysWHERE nom like '%SearchString%' or web_url like '%SearchString%' or organisation like '%SearchString%' or pays like '%SearchString%' AND contacts.code_pays_rel=pays.code_paysORDER BY pays, organisation, nom ASCResult: 236 !!!
What I am doing wrong?A lot of thx for your help and time.Regards, Dominique Javet