Use a subquery instead of JOIN to write your solution

3207 views sql
7

I have 2 tables one with the names of the planes and model and the other with the models and Id

I keep getting 0

select count(Model) AS NUMANGELS 
from Aircraft
WHERE  model = (SELECT Aname 
                FROM AircraftTypes
                where aname = 'Dark Angel' )

answered question

This is a very strange subquery since you are selecting the same column you have in the where clause. You might as well skip the whole sub query and change the where clause in your main query to WHERE model = 'Dark Angel' although I guess there is more that is not correct with your query.

I suggest you add some sample data and the expected output.

1 Answer

13

You want where model in (some list of models) not = ...and you're selecting aname. You need to return model from the inside select to select model from aircraftTypes where aname = '...' Remember whatever you select on the inside has to match the thing on the outside.

posted this

Have an answer?

JD

Please login first before posting an answer.

Ads

Categories