Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting non-matching records from two tables
Message
De
23/11/2001 08:47:24
 
 
À
23/11/2001 08:05:26
Christopher Pinnock
United General Insurance Company
Kingston, Jamaique
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00585108
Message ID:
00585116
Vues:
20
Chris,
Not sure if I fully understand your question. If you're looking for roles that have no matching records in GrantRoles table, then you could use something like this:
*-- create some test data
CREATE CURSOR roleAll (id i)
FOR i = 1 TO 1000
   INSERT INTO roleAll VALUES(i)
ENDFOR

CREATE CURSOR roleGrant (id i)
FOR i = 1 TO 1000 STEP 4
   INSERT INTO roleGrant VALUES(i)
ENDFOR &&* i = 1 TO 1000

*-- A) using a sub-query
SELECT * FROM RoleAll WHERE id NOT IN(SELECT id FROM RoleGrant)

*-- or B) using a LEFT JOIN
SELECT RoleAll.*;
 FROM RoleAll;
  LEFT JOIN RoleGrant ON RoleAll.id = RoleGrant.id;
 WHERE ISNULL(RoleGrant.id)
If I missunderstood your question, maybe you could post some more information.

HTH
>I have two tables. The first of which have all roles availale the next have roles granted to a particular user. How do i select the rows that do not match.
>
>Access acheives this by using the left outer join. I have tried the same technique in Visual Foxpro 6 and SQLSERVER 7 and it does not work. Any ideas ???
>
>Chris
Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform