Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
I'd say that your first query already does that.
The UNION statement is used to join the result of 2 queries, and the 2 queries you join are
1) SELECT * FROM submenu WHERE submenu.parent NOT IN (select id from topmenu)
and
2)SELECT * FROM topmenu
So, in the result of that query:
Code:
SELECT * FROM submenu WHERE submenu.parent NOT IN (select id from topmenu)
union
SELECT * FROM topmenu
, and as far as the type and numbers of columns are the same, you will get every rows from topMenu, and every rows from subMenu who does not have a parent defined in topMenu.
__________________
Only a biker knows why a dog sticks his head out the window.
|