I want to retrieve some date from 2 different tables action and staff.
This is my code:
SELECT ActionID, FeedbackID, StaffID, ActionDate, ActionDetails,
(SELECT StaffName, Department
FROM staff
WHERE staff.StaffID=action.StaffID)
FROM action;
I am getting this error:
#1241 – Operand should contain 1 column(s)
Best Answer
Your error comes from having two outputs in the SELECT sub-query.
Solution: Having 1 sub-query per output should work if each only returns one value.
Warning: If your sub-query returns multiple outputs, you'll receive an error. Thus, it is best practice to use SELECT sub-queries for known single outputs, like COUNT or SUM.
For multiple outputs: Please use joins, for example: