MySQL select query in where clause

47,767

You need a from clause before the where:

SELECT *
FROM <some table here>
WHERE `id` IN (SELECT unit_trust_managing_company_id FROM ut_funds)

Also, the distinct and order by are not needed for the in statement.

Share:
47,767
Dinuka Thilanga
Author by

Dinuka Thilanga

I was software engineer at eMarketingeye. Now i am Senior Software engineer at eFutures.

Updated on December 23, 2020

Comments

  • Dinuka Thilanga
    Dinuka Thilanga over 3 years

    Can u correct this query? it is show some syntax error.

    SELECT * 
     WHERE `id` IN (SELECT DISTINCT unit_trust_managing_company_id 
                      FROM ut_funds 
                     ORDER BY `company_name`)
    

    There SELECT DISTINCT unit_trust_managing_company_id FROM ut_funds ORDER BYcompany_name` query is working properly.