Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IDCard or not
Message
 
To
31/01/2013 12:06:00
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01564852
Message ID:
01564858
Views:
44
>Hi,
>
>I have 2 tables:
>
>Employee table 2 fields:
>
>EmpID EmpName
>11111 JoeBlo
>22222 JackWhite
>33333 JohnBlack
>44444 MaryGreen
>55555 MeeLee
>66666 SeeLoo
>77777 TeeNoo
>
>
>Idcard table 2 fields:
>
>EmpID ExpireDate
>11111 01/31/2013
>22222 02/28/2013
>33333 03/31/2013
>44444 04/30/2013
>55555 12/31/2012
>
>Find all employees either without an IDcard or with one that has expired ?
>
>SELECT * FROM Employee WHERE EmpID not IN(SELECT IDCard.EmpID FROM IdCard);
>
>How do I do to have with one that has expired like empID = 55555
>
>Thank you,
*** Find ALL with no ID or with Expired ones
SELECT Employee.*;
FROM Employee;
LEFT JOIN IdCard ON Employee.EmpID   = IdCard.EmpID AND IdCard.ExpireDate >= DATE();
WHERE IdCard.EmpID IS NULL

*** Find ALL with expired IDs
SELECT Employee.*;
FROM Employee;
INNER JOIN IdCard ON Employee.EmpID   = IdCard.EmpID;
WHERE IdCard.ExpireDate < DATE();
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform