-- Find galaxies that are blended with a star.
-- Output the deblended galaxy magnitudes. 
-- This query introduces the use of multiple tables or views. You can assign
-- nicknames to tables as in the FROM clause below. Since you are using
-- multiple tables, you must specify which table each quantity in the SELECT
-- clause comes from.  The query illustrates the JOIN syntax between
-- the two tables, which requires that a common quantity that is present in
-- both tables be equal, in this case their common parent object.

SELECT top 1000 G.ObjID, G.u, G.g, G.r, G.i, G.z 
FROM  Galaxy G                                  -- compare Galaxy and Star
      JOIN Star S ON G.parentID = S.parentID    -- using the same parent
WHERE 
   G.parentID > 0   -- if the galaxy has a "parent", this object was deblended

