Comparaison SQL

2pax.cruz -  
malaik5 Messages postés 259 Date d'inscription   Statut Membre Dernière intervention   -
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 :)

7 réponses

  1. Kino76 Messages postés 93 Statut Membre 3
     
    peut tu nous donner la requete?
    0
  2. Veg4s Messages postés 39 Statut Membre 1
     
    Avec la requête cela serait beaucoup plus simple :)
    0
  3. 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
  4. 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
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. malaik5 Messages postés 259 Date d'inscription   Statut Membre Dernière intervention   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
    1. 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
  7. 2pax.cruz
     
    Merci de votre aide.

    J'ai refait une requête avec une LEFT JOIN.
    0
  8. malaik5 Messages postés 259 Date d'inscription   Statut Membre Dernière intervention   33
     
    si ça marche,
    Merci de mettre le poste en résolu
    0