Requête MySQL : AND puis OR
Posté : 11 févr. 2009, 17:40
Bonjour à tous,
Je cherche une solution pour rechercher dans une base de donnée avec OR puis avec AND si aucun résultat n'a été proposé. Et cela pour trois champs.
Exemple :
Puis si rien n'est retourné :
Puis :
Voici la base de données :
Merci d'avance pour votre aide 
Je cherche une solution pour rechercher dans une base de donnée avec OR puis avec AND si aucun résultat n'a été proposé. Et cela pour trois champs.
Exemple :
Code : Tout sélectionner
SELECT * FROM base WHERE champ1 LIKE "test" AND champ2 LIKE "vivelephp" AND champ3 LIKE "phpfrance"
Code : Tout sélectionner
SELECT * FROM base WHERE champ1 LIKE "test" AND champ2 LIKE "vivelephp" OR champ3 LIKE "phpfrance"
Code : Tout sélectionner
SELECT * FROM table WHERE champ1 LIKE "test" OR champ2 LIKE "vivelephp" OR champ3 LIKE "phpfrance"
Code : Tout sélectionner
CREATE TABLE IF NOT EXISTS `table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`champ1` text NOT NULL,
`champ2` text NOT NULL,
`champ3` text NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8;