Results 1 to 2 of 2
  1. #1
    acdougla17 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    4

    Need to do and exclusive-or SQL query

    Display all the columns in Department for those that have rows in Employee or Project but not both.
    - Department has column code.


    - Employee has dcode (foreign key to Department).
    - Project has dcode (foreign key to Department).

    From what I can tell, there is no XOR in Access so I am not quite sure how to set it up. This is my attempt at it and it may not even be close as I am not very good at this.

    Code:
    SELECT *
    FROM Department
    WHERE EXISTS(SELECT * FROM Employee WHERE Department.code = Employee.dcode)
    OR EXISTS(SELECT * FROM Project WHERE Department.code = Project.dcode)
    AND NOT EXISTS(SELECT * FROM Project,Employee WHERE Department.code = Employee.dcode AND Project.dcode = Employee.dcode);

    Can I even use OR EXISTS followed by AND EXISTS?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Try:

    SELECT Department.*
    FROM Project RIGHT JOIN (Employee RIGHT JOIN Department ON Employee.dCode = Department.Code) ON Project.dCode = Department.Code
    WHERE (Not Employee.dCode Is Null AND Project.dCode Is Null) OR (Employee.dCode Is Null AND Not Project.dCode Is Null);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Exclusive access/DB lock
    By Boru in forum Access
    Replies: 18
    Last Post: 07-28-2014, 01:38 AM
  2. exclusive mode
    By raffie77 in forum Access
    Replies: 7
    Last Post: 01-24-2012, 10:27 PM
  3. Replies: 4
    Last Post: 08-13-2011, 12:34 PM
  4. Open Exclusive Code
    By AKQTS in forum Access
    Replies: 2
    Last Post: 08-11-2011, 10:51 AM
  5. User always appear to connect with exclusive rights
    By kblinkhorn in forum Security
    Replies: 18
    Last Post: 09-02-2010, 01:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums