CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Nov 2007
    Posts
    38

    WHERE clause with multiple values from one field [Access]

    Hello i have created database of Employees and their rights to access many areas, using MS Access(see the attached image of my database schema)

    now, lets say i want to select ALL EmployeeIDs from r_rights table, who have access to areas 1 OR 5,
    here is my SQL code:
    SELECT r_rights.EmployeeID, r_rights.AreaID
    FROM r_rights
    WHERE r_rights.AreaID = 1 OR r_rights.AreaID = 5;


    it returns all EmployeeIDs who has access to area1 or area5

    But what if i want to list ONLY EmployeeIDs who have access to area1 AND area5?

    i tried to put this line in the above code:
    WHERE r_rights.AreaID = 1 AND r_rights.AreaID = 5;

    but it didnt work...no errors, but it didnt give any results


    similiar problem comes out when i want to select, for example all employees whoose card expires on 5th month of 2008 year... here is the SQL for it:

    SELECT e_employees.FirstName, e_employees.LastName, e_employees.FathersName, d_divisions.DivisionName, t_titles.TitleName, e_employees.CardExpireDate
    FROM t_titles INNER JOIN (d_divisions INNER JOIN e_employees ON d_divisions.DivisionID = e_employees.DivisionID) ON t_titles.TitleID = e_employees.TitleID
    WHERE (Year(CardExpireDate)) = 2008 AND (Month(CardExpireDate)) = 5;

    no errors, but it doesnt show any record...

    please help me to solve these problems, thank you
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured