क्वेरी अपडेट करने के लिए धन्यवाद; अब हम देख सकते हैं कि WHERE शर्त केवल अंतिम . पर लागू होती है यूनियन क्वेरी। आपको या तो . चाहिए प्रत्येक क्वेरी में WHERE क्लॉज जोड़ें, या इसे सब-सेलेक्ट के रूप में लपेटें और उस पर WHERE क्लॉज लागू करें।
select s.id as id, s.email as email, s.password as password, s.role as role from tblStudents s
where email = "[email protected]"
union
select a.id as id, a.email as email, a.password as password, a.role as role from tblAdmin a
where email = "[email protected]"
union
select t.id as id, t.email as email, t.password as password, t.role as role from tblTeachers t
where email = "[email protected]"
या
SELECT * FROM (
select s.id as id, s.email as email, s.password as password, s.role as role from tblStudents s
union
select a.id as id, a.email as email, a.password as password, a.role as role from tblAdmin a
union
select t.id as id, t.email as email, t.password as password, t.role as role from tblTeachers t
) foo where email = "[email protected]"