Bonjour à tous
J'ai un ensemble deux tables comme suit :
Je voudrai faire une requète SELECT qui me retourne les id_product (de la table product_productextras) correspondant à des id_pei contenant bien trois tuples dans la table product_productextras_lang (un par id_lang soit dans mon cas un tuple avec id_lang à 1. et deux autre pour les id_lang 2 & 3). J'aimerai aussi faire ressortir les id_product associés des id_pei qui aurai des valeurs vide soit pour leur champs notice et about.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 CREATE TABLE IF NOT EXISTS `product_productextras` ( `id_pei` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id_product` int(10) UNSIGNED NOT NULL, PRIMARY KEY (`id_pei`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `product_productextras_lang` ( `id_pei` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id_lang` int(10) unsigned NOT NULL, `notice` text DEFAULT NULL, `about` text DEFAULT NULL, PRIMARY KEY (`id_pei`, `id_lang`), CONSTRAINT `fk_productextras_id_pei` FOREIGN KEY (`id_pei`) REFERENCES `'._DB_PREFIX_.'product_productextras`(`id_pei`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Exemple avec cette table :
Est ce possible ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 +---------+---------+------+---------+ | product_productextras_lang | +---------+---------+-------+--------+ | id_pei | id_lang | notice | about | +---------+---------+-------+--------+ | 1 | 1 | x | x | | 1 | 2 | x | x | | 1 | 3 | x | x | | 2 | 1 | x | x | | 2 | 2 | x | x | | 2 | 3 | x | x | | 3 | 1 | x | x | | 3 | 2 | x | x | | 3 | 4 | x | x | | 4 | 1 | x | x | | 4 | 2 | x | x | | 5 | 1 | | | | 5 | 2 | | | | 5 | 3 | | | | 6 | 1 | x | x | | 6 | 2 | | | | 6 | 3 | x | x | +---------+---------+-------+--------+
Merci d'avance pour vos idées![]()
Partager