Shan Liu3,612 Points
So in the case of where there are duplicate values like with the BMW or the Honda because of their id numbers being different, how would we exclude them? Would it be with a DISTINCT/GROUP BY combo that allows you to filter out the duplicates? or is there a different keyword that is being used for this certain circumstance?
Steven Parker202,001 Points
GROUP BY can be used to eliminate duplicates.
Generally, you'd use
GROUP BY if your output contained at least one aggregate value, and
But for this exercise, combining with UNION works, as it implies "distinct", just remember that it applies to all displayed columns. To get only distinct makes, that means you would display the MakeName but not the MakeId. If the MakeId is displayed, then the rows are not duplicates.
kevin hudsonPro Student 9,652 Points
@Steven Parker I thought the same thing but DISTINCT and GROUP BY does nothing. When joining we see Make and ForeignMake tables info where BMW is listed twice but has different ID's. I am assuming that we are stuck with that unless we add another WHERE condition:
SELECT * FROM Make WHERE MakeName < "D" AND MakeName != "BMW" UNION SELECT * FROM ForeignMake WHERE MakeName < "D" AND MakeName != "BMW" ORDER BY MakeName;