Wednesday 18 September 2013

mysql query output projector and whiteboard

mysql query output projector and whiteboard

I've got this small assignment: Find those rooms that have projectors, but
not whiteboards.
CREATE TABLE Equipment (
room VARCHAR(15),
type VARCHAR(20)
);
INSERT INTO Equipment VALUES ('Dreyer-201','projector');
INSERT INTO Equipment VALUES **('Zuse-127','projector');**
INSERT INTO Equipment VALUES ('Shannon-164','projector');
INSERT INTO Equipment VALUES ('Dreyer-201','whiteboard');
INSERT INTO Equipment VALUES **('Zuse-127','whiteboard');**
INSERT INTO Equipment VALUES ('Shannon-164','whiteboard');
This is my answer:
SELECT DISTINCT room, type
FROM Equipment
WHERE type = 'projector' AND NOT type = 'whiteboard'
And it is working - but my output lists the room Zuse-127. I know it
stands alone with both projector and whiteboard, but how can I fix this
problem? So the room Zuse-127 does not show.
Thx for your time ;)

No comments:

Post a Comment