I want to update data table for those who score exam id 1,2 more than 80. I try this
UPDATE data
SET column = 'value'
WHERE
(SELECT * FROM exams
WHERE (id = '1' AND score >= 80) AND (id = '2' AND score >= 80));
It gives me 0 result. But it should have few hundreds results ANy help??
I think the problem is this:
SELECT * FROM exams
WHERE (id = '1' AND score >= 80) AND (id = '2' AND score >= 80)
It gives 0 result. How to select those who score more than 80 points for both exam 1 and 2??
You query won’t work because you’re asking for exams that have id = 1 AND id = 2.
Assuming that id cannot hold two values at the same time, you’ll never return any results.
Try this as the basis of your update instead :-
Edited based on comment :-
User wants only people who scored more than 80 for both exams. Assuming personid is a key to the person who took the exam.