0
5th q in challenge says that we need tge ages of lions and bears. but according to the given answer they are using IN clause which means lions or crocodiles and bears or birds. so how come this? Is it a mistake?
4 Antworten
+ 1
It depends on how you read it, the first sentence states that you Need the ages of bears and lions, however they also clarify that the result of query one will return ages of bears and birds, same with query two except its crocodiles and lions.
However seeing how theres no good way of knowing which rows are what animal in the result a
more correct query would be:
SELECT age
FROM zoo1
WHERE animal = 'bear'
UNION
SELECT age
FROM zoo2
WHERE animal ='lion'
Or if you keep the queries in the question as is and also select the animal column, then you'd get a result table where you could filter on the animals you want.
+ 1
Union combines the result sets from the queries and remove any duplicates.
Union all combines the result sets but keeps all the rows.
0
what is difference union and union all??
0
yeap understand .thanks