MySQL Forums
Forum List  »  Newbie

Basic Join... I think
Posted by: Kristie McNickles
Date: November 28, 2006 06:32PM

I need help figuring out a problem...

I have two tables:
FIELDS -- (field_id*, agreedname, parentelement)
STATES -- (id*, field_id, state_abbr)

I need to populate a tree with all the possible agreednames (like this):
select agreedname from fields where parentelement = 'AddAdjustments';

I also need to highlight the nodes of this tree that belong to a given state. For instance, if NY is logged in, I want all the nodes to display, but NY nodes will be yellow.

I don't want to run a query within each resultset. Is there a way to do some sort of join that will bring me back all distinct fields in FIELDS (for a given parentelement) and will also bring me some sort of indicator if the STATES table contains an entry with state_abbr = 'NY'?

My join skills suck. I can merely bring back all the fields for the given state, but obviously this is not enough.

select
a.field_id,
a.agreedname
from
fields a,
state_info b
where
a.parentelement = 'AddAdjustments' and
b.state_abbr = 'NY' and
a.field_id = b.field_id;

Any help is appreciated...

Options: ReplyQuote


Subject
Written By
Posted
Basic Join... I think
November 28, 2006 06:32PM
November 28, 2006 09:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.