If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Filtering query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-10, 12:31
oldnickj oldnickj is offline
Registered User
 
Join Date: Jan 2009
Posts: 103
Filtering query

This query produces a list of names(RESULTS) which correctly includes two parent(s) by virtue of the union. What I need now is to eliminate the name "Kids" from RESULTs because "Kids" are replaced by the two name_mnu results.

Logic: List all "parent" and all "name_mnu" (as parent) but filter out and parent whose name_mnu is not null. See attachment:

This will be a menu list of pages (parent) where if the page has
Query:

SELECT name_mnu
FROM menu m1
WHERE name_mnu IS NOT NULL
UNION
SELECT parent
FROM menu m2
WHERE name_mnu IS NULL
ORDER BY name_mnu

RESULTS:

About
Contact
Education
Entertainment
HOME
Kid's Place
Kids
Login
Press Room
Sponsors
Ticket/Events
Trash art


Nick
Attached Thumbnails
Filtering query-screen-shot-2010-01-23-9.11.17-am.png  
Reply With Quote
  #2 (permalink)  
Old 01-24-10, 08:04
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
nick, i was gonna give your query a try, and then i took a look at your data

something seems really, really wrong

could you please explain the purpose of each column
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-24-10, 11:35
oldnickj oldnickj is offline
Registered User
 
Join Date: Jan 2009
Posts: 103
The Results list is is a list of pages in a menu system for a web site. In the attachement you can see that KIDS (on parent) has two subordinate items which are sub-menu items. I need a list of all of parent where name_mun IS NULL, and all of name_mnu where name_menu IS NOT NULL, ordered alphabetically.

So RESULTS which not have KIDS and I would like to name the resulting column "CSSMENU".

Nick
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On