Mysql exists subquery can be divided into: from where and exists subquery www.2cto.com classification table: [SQL] mysql> select * from category; + ---- + --------- + | id | c_name | + ---- + --------- + | 1 | ios | 2 | android | 3 | sb | + ---- + --------- + 3 rows in set item table: www.2cto.com [SQL] mysql> select * from goods; + ---- + --------- + -------- + ------- + | id | name | cat_id | price | num | + ---- + --------- + -------- + ------- + ----- + | 1 | Apple | 1 | 4999 | 2 | 2 | nexus4 | 2 | 1999 | 3 | 4 | glory 2 | 2 | 1888 | 5 | 6 | Samsung | 2 | 3000 | 2 | + ---- + --------- + -------- + ------- + ----- + 6 rows in se www.2cto.com requirements: only find the category of the item under the category [SQL] mysql> select * from category c where exists (select * from goods where cat_id = c. id); + ---- + --------- + | id | c_name | + ---- + --------- + | 1 | ios | 2 | android | + ---- + --------- + 2 rows in set