Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
select pr.payment_id from programs pr where pr.program='After School' OR pr.program='Night Classes' OR pr.program='Camp' or pr.program='Hapkido' OR pr.program='Krav Maga'
Doesn't that have 5 IDs?There shouldn't be more than one row in the subquery, since there's only one payment id.You might want to use some kind of tool like phpMyAdmin to inspect the table. Is the payment id marked UNIQUE? Or is it an AUTO_INCREMENT key? If not, you may be looking at data pollution.
WHERE pr.program = 'After School'
OR pr.program = 'Night Classes'
OR pr.program = 'Camp'
OR pr.program = 'Hapkido'
OR pr.program = 'Krav Maga'
From just that where clause it seems that there are (at least) 5 possible programs so 5 possible rows could be returned. Even if all rows have the same payment_id there is still the possibility of more than one row. It is the number of rows being greater than one that causes the error message.SELECT
p.*
FROM payment p
WHERE p.student_id = '51'
OR p.sibling_1 = 'Kimberley Oakley'
OR p.sibling_2 = 'Kimberley Oakley'
OR p.sibling_3 = 'Kimberley Oakley'
AND EXISTS (
SELECT 1
FROM programs pr
WHERE (pr.program = 'After School'
OR pr.program = 'Night Classes'
OR pr.program = 'Camp'
OR pr.program = 'Hapkido'
OR pr.program = 'Krav Maga')
AND pr.payment_id = p.id
)
ORDER BY
p.payment_date DESC
LIMIT 1
;
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Your Current Statement
Open in new window
Please change to
Open in new window