Keren Keren - 6 months ago 7
SQL Question

Subqueries with EXISTS

I want to select main menu if each of it has submenu in another table. Below is my query:

SELECT * FROM main_menu m WHERE EXIST('select * from menu w where w.main_menu_id = m.main_menu_id')


But phpmyadmin gives an error which reads:

#1305 - FUNCTION smartsaf_maxura.EXIST does not exist


Can anyone explain what went wrongly here?

Answer

This shuld work

SELECT * FROM main_menu  m WHERE EXISTS(select * from menu w where w.main_menu_id = m.main_menu_id)