Shani Mughal
Shani Mughal

Reputation: 105

insert query isn't working

enter image description here

INSERT INTO EmployeePrivileges (EmployeeID, PrivilegeID)
VALUES (
(SELECT ID
FROM Employees
WHERE Employees.JobTitle = 'Sales Manager'), 
(SELECT PrivilegeID
FROM Privileges
WHERE Privileges.PrivilegeName = 'Day opening and closing'));

I'm trying to run the above query in Ms Access but following error occurs " error query input must contain at least one table or query" what to do?

Upvotes: 0

Views: 74

Answers (1)

Jim Sosa
Jim Sosa

Reputation: 628

I haven't used ms-access in some time, but as long as those 2 queries are just returning 1 row each you could combine them:

INSERT INTO EmployeePrivileges (EmployeeID, PrivilegeID)
    SELECT e.ID, p.PrivilegeID
     FROM Employees e, Privileges p
    WHERE e.JobTitle = 'Sales Manager'
      AND p.PrivilegeName = 'Day opening and closing';

Upvotes: 1

Related Questions