Requirement
Find and display all pilots (employee ID and name) who implemented flights on the planes of 'Commuter' type and ‘Normal’ type.
1st image is Plane_new table
2nd image is FlightI_new table
3rd image is Employee_new table
Solution
SELECT flightI_new.eid, employee_new.ename
FROM flightI_new
INNER JOIN employee_new ON flightI_new.eid = employee_new.eid
INNER JOIN plane_new ON flightI_new.pnum = plane_new.pnum
WHERE plane_new.ptype = 'Commuter' AND plane_new.ptype = 'Normal';
The code works with OR, but for some reason with AND i get "no rows returned".
Any idea how to solve it?
Your
AND
does not work because records cannot have bothptype
on the same record. But you should be able to use something like this:See SQL Fiddle with Demo
Of you can use something like this:
See SQL Fiddle with Demo
the wrong is here
plane_new.ptype cant have two things ,computer and normal in your database, it must be one of them thats why u get no rows returned. so maybe you mean something else. here in your WHERE statment u can use only
OR
. and they the rows returned are those who havecomputer
andnormal