Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting non-matching records from two tables
Message
From
23/11/2001 08:47:24
 
 
To
23/11/2001 08:05:26
Christopher Pinnock
United General Insurance Company
Kingston, Jamaica
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00585108
Message ID:
00585116
Views:
19
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
Previous
Reply
Map
View

Click here to load this message in the networking platform