Comment utiiser FULL JOIN ?

ephelya Messages postés 296 Statut Membre -  
blackmefias_3350 Messages postés 710 Date d'inscription   Statut Membre Dernière intervention   -

Bonjour,

J'ai  dans ma bdd une table listant des appartements
 

CREATE TABLE `apparts` (
  `id` int(5) NOT NULL,
  `nom` varchar(50) DEFAULT NULL,
  `nbpieces` int(2) DEFAULT NULL,
  `type` int(2) DEFAULT NULL,
  `meuble` int(1) DEFAULT NULL,
  `idzone` varchar(4) DEFAULT NULL,
  `loyer` varchar(10) DEFAULT NULL,
  `adresse1` varchar(50) DEFAULT NULL,
  `adresse2` varchar(50) DEFAULT NULL,
  `cpost` int(5) DEFAULT NULL,
  `ville` varchar(50) DEFAULT NULL,
  `pays` varchar(50) DEFAULT NULL,
  `dateadd` int(50) DEFAULT NULL,
  `surface` int(4) NOT NULL,
  `dpe` text NOT NULL,
  `firstpub` int(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 une table listant les aménagements pour chaque appartement

CREATE TABLE `equip_apparts` (
  `id` int(5) NOT NULL,
  `idappart` int(5) NOT NULL,
  `idelem` int(5) NOT NULL,
  `prio` int(2) NOT NULL,
  `requis` int(1) NOT NULL,
  `check` int(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

et la table des éléments en question

CREATE TABLE `amenagement` (
  `id` int(5) NOT NULL,
  `element` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

J'ai besoin de lister pour chaque appartement tous les équipements, qu'ils soient présents ou non donc j'ai voulu tenter cette requete full join :
 

SELECT * FROM `apparts` A
FULL JOIN 
(SELECT x.id idelem, element, idappart, prio, requis  
FROM amenagement x 
LEFT JOIN equip_apparts eq ON eq.idelem = x.id) B ON B.idappart = A.id

et ça me répond

Erreur de syntaxe près de 'FULL JOIN
(
SELECT x.id idelem, element, idappart, prio, requis, `check` F...' à la ligne 2

À vrai dire je n'ai jamais réussi à faire une requête full join, alors que ça semble plus que basique...
Qu'est-ce que je fais mal ??
Merci d'avance pour votre aide ! :-)
Macintosh / Firefox 102.0

2 réponses

  1. blackmefias_3350 Messages postés 710 Date d'inscription   Statut Membre Dernière intervention   70
     

    bonjour,

    la syntaxe ne serai pas  SELECT * FROM 'apparts' AS FULL JOIN ? 

    SELECT * FROM `apparts` AS
    FULL JOIN 
    (SELECT x.id idelem, element, idappart, prio, requis  
    FROM amenagement x 
    LEFT JOIN equip_apparts eq ON eq.idelem = x.id) B ON B.idappart = A.id

    0