Comparaison SQL

2pax.cruz -  
malaik5 Messages postés 282 Statut Membre -
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 :)
A voir également:

7 réponses

Kino76 Messages postés 93 Statut Membre 3
 
peut tu nous donner la requete?
0
Veg4s Messages postés 39 Statut Membre 1
 
Avec la requête cela serait beaucoup plus simple :)
0
2pax.cruz
 
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"]));
0
Veg4s Messages postés 39 Statut Membre 1
 
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"]);
?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
malaik5 Messages postés 282 Statut Membre 33
 
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
0
Veg4s Messages postés 39 Statut Membre 1
 
à mon avis c'est une requête qui est générée automatiquement pas Acces, c'est pour ça qu'elle est si compliquée est mal optimisée.
0
2pax.cruz
 
Merci de votre aide.

J'ai refait une requête avec une LEFT JOIN.
0
malaik5 Messages postés 282 Statut Membre 33
 
si ça marche,
Merci de mettre le poste en résolu
0