Sql select multiple values from another query Sql select multiple values from another query database database

Sql select multiple values from another query


to be more safe with subquery, use IN instead of =

SELECT name FROM   fact Where id IN (SELECT fact_id              FROM   product_fact              WHERE  product_id='1125');

or using JOIN

SELECT  DISTINCT a.nameFROM    fact a        INNER JOIN product_fact b            ON a.ID = b.fact_IDWHERE   b.product_ID = '1125'