I have webpage that has its "pages/articles" stored in a MySQL database. It also has a feature to show a different side menu for different pages. All that (menus, menu's items) is stored in DB.
Here's my SQL for getting all menu items for current page:
SELECT *
FROM menu_items
JOIN pages
ON menu_items.menu_id=pages.right_menu_id
WHERE pages.link = "some_link"
and it works.
What I want is, when this query returns an empty set, to execute another query and get its result instead. Is it possible ?? If query mentioned above is empty, I would like to get result of this query:
SELECT *
FROM menu_items
WHERE menu_id=2;
Is it possible, or should I just do it in PHP ?