Comparaison SQL
Bonjour, bonjour.
J'espère que vous saurez m'aider mais j'ai une question en SQL.
Sur Access, j'essaye de faire une requête.
J'ai une requête qui comporte plusieurs SELECT liés par UNION. Il y a également une clause WHERE.
Lorsque j'execute ma requête, aucun problème.
Mais on me demande de retrouver les différences entre deux résultats de cette requête si on les execute avec une variable différente (variable utilisée dans la clause WHERE)
Pouvez-vous m'aider ?
Je vous remercie d'avance :)
J'espère que vous saurez m'aider mais j'ai une question en SQL.
Sur Access, j'essaye de faire une requête.
J'ai une requête qui comporte plusieurs SELECT liés par UNION. Il y a également une clause WHERE.
Lorsque j'execute ma requête, aucun problème.
Mais on me demande de retrouver les différences entre deux résultats de cette requête si on les execute avec une variable différente (variable utilisée dans la clause WHERE)
Pouvez-vous m'aider ?
Je vous remercie d'avance :)
7 réponses
-
peut tu nous donner la requete?
-
Avec la requête cela serait beaucoup plus simple :)
-
Bon courage :)
SELECT [Drive_O Attribute with User].Path, [Drive_O Attribute with User].Access, [Drive_O Attribute with User].fullname, [Drive_O Attribute with User].NameSG1, [Drive_O Attribute with User].NameSG2, [Drive_O Attribute with User].NameSG3, [Drive_O Attribute with User].NameSG4, [Drive_O Attribute with User].NameSG5 FROM [Drive_O Attribute with User] WHERE ((([Drive_O Attribute with User].fullname) Like ["Initiales"])) UNION SELECT [Drive_O Attribute with User].Path, [Drive_O Attribute with User].Access, [Drive_O Attribute with User].fullname, [Drive_O Attribute with User].NameSG1, [Drive_O Attribute with User].NameSG2, [Drive_O Attribute with User].NameSG3, [Drive_O Attribute with User].NameSG4, [Drive_O Attribute with User].NameSG5 FROM [Drive_O Attribute with User] WHERE ((([Drive_O Attribute with User].NameSG1) Like ["Initiales"])) UNION SELECT [Drive_O Attribute with User].Path, [Drive_O Attribute with User].Access, [Drive_O Attribute with User].fullname, [Drive_O Attribute with User].NameSG1, [Drive_O Attribute with User].NameSG2, [Drive_O Attribute with User].NameSG3, [Drive_O Attribute with User].NameSG4, [Drive_O Attribute with User].NameSG5 FROM [Drive_O Attribute with User] WHERE ((([Drive_O Attribute with User].NameSG2) Like ["Initiales"])) UNION SELECT [Drive_O Attribute with User].Path, [Drive_O Attribute with User].Access, [Drive_O Attribute with User].fullname, [Drive_O Attribute with User].NameSG1, [Drive_O Attribute with User].NameSG2, [Drive_O Attribute with User].NameSG3, [Drive_O Attribute with User].NameSG4, [Drive_O Attribute with User].NameSG5 FROM [Drive_O Attribute with User] WHERE ((([Drive_O Attribute with User].NameSG3) Like ["Initiales"])) UNION SELECT [Drive_O Attribute with User].Path, [Drive_O Attribute with User].Access, [Drive_O Attribute with User].fullname, [Drive_O Attribute with User].NameSG1, [Drive_O Attribute with User].NameSG2, [Drive_O Attribute with User].NameSG3, [Drive_O Attribute with User].NameSG4, [Drive_O Attribute with User].NameSG5 FROM [Drive_O Attribute with User] WHERE ((([Drive_O Attribute with User].NameSG4) Like ["Initiales"])) UNION SELECT [Drive_O Attribute with User].Path, [Drive_O Attribute with User].Access, [Drive_O Attribute with User].fullname, [Drive_O Attribute with User].NameSG1, [Drive_O Attribute with User].NameSG2, [Drive_O Attribute with User].NameSG3, [Drive_O Attribute with User].NameSG4, [Drive_O Attribute with User].NameSG5 FROM [Drive_O Attribute with User] WHERE ((([Drive_O Attribute with User].NameSG5) Like ["Initiales"]));
-
Je comprends bien le SQL mais j'ai beaucoup de mal avec acces :D à quoi correspond la table FROM [Drive_O Attribute with User]?
Cette grosse requete ne serait elle pas plus simple avec :
Select * from Ta_table where
([Drive_O Attribute with User].NameSG5) Like ["Initiales"])
or
([Drive_O Attribute with User].NameSG1) Like ["Initiales"])
or
([Drive_O Attribute with User].NameSG2) Like ["Initiales"])
or
([Drive_O Attribute with User].NameSG3) Like ["Initiales"])
or
([Drive_O Attribute with User].NameSG4) Like ["Initiales"])
oe
([Drive_O Attribute with User].NameSG5) Like ["Initiales"]);
? -
Bonjour,
J'ai eu du mal à lire la requete aussi,
Mais je voulais juste savoir, si t'as pu écrire une requete aussi compliquée que celle là, tu ne sauras pas répondre à ta simple question ??
et en plus ce qu'il faut savoir c'est que les jointures sont vraiment gourmandes en temps de réponses donc si on peut les éviter au max c'est impécable
Bon courage -
Merci de votre aide.
J'ai refait une requête avec une LEFT JOIN. -
si ça marche,
Merci de mettre le poste en résolu