Reputation: 33
SELECT c.Staff_no, c.Start_datetime, c.End_datetime, s.First_name, s.Profession, s.Department, s.Gender
FROM duty_roster_1501003f c, staff_1501003f s where c.Staff_no = s.Staff_no IN
(SELECT Staff_no, Start_datetime, End_datetime FROM duty_roster_1501003f WHERE Remarks = 'overtime' ORDER BY staff_no);
The error code says Operand should contain 1 column(s). What should i do to fix it?
Upvotes: 1
Views: 103
Reputation: 529
Where you say:
... WHERE c.Staff_no = s.Staff_no IN (SELECT Staff_no, Start_datetime, End_datetime FROM duty_roster_1501003f WHERE Remarks = 'overtime' ORDER BY staff_no);
That is not valid. Maybe you want:
... WHERE c.Staff_no = s.Staff_no AND c.Staff_no IN
(SELECT Staff_no FROM duty_roster_1501003f WHERE Remarks = 'overtime')
A select for an IN
can only return 1 column (what would you have it do with the other columns?)
Upvotes: 1
Reputation: 910
You're missing an AND/OR and a field name before IN
WHERE c.Staff_no = s.Staff_no AND someField IN (Subquery)
Also, the subquery should return only one field, and not 3 as you're returning now.
Upvotes: 1