I'm having trouble figuring out a tricky sql problem. Any help is greatly appreciated.
Using the following tables:
event
- event_id
- event_type_id
- start_date
event_type
- event_type_id
- event_name
event_category
- event_category_id
- category_name
event_cat_relation
- er_cat_id
- event_id
- event_category_id
To populate an html select box, I'd like to query for event_id and event_name. I can use the following sql to get the data, but duplicates are persistent. Despite numerous variations of the sql, I cannot remove the dupes.
SQL
=============
select e.event_id, t.name
from event e, event_type t, event_cat_relation r
where e.event_type_id = t.event_type_id and e.event_id = r.event_id
order by t.name
RESULTSET
=============
EVENT_ID NAME
1567 Exercise and the Personality
1567 Exercise and the Personality
1567 Exercise and the Personality
1227 Expectant Fathers
1227 Expectant Fathers
1232 Expectant Grandparents
1231 Expectant Grandparents
1579 Health Insurance: Am I Covered?
1579 Health Insurance: Am I Covered?
1213 Health on the Net
1573 Heart Failure Prevention and Treatment
1573 Heart Failure Prevention and Treatment
Thanks for any help.
michael
Using the following tables:
event
- event_id
- event_type_id
- start_date
event_type
- event_type_id
- event_name
event_category
- event_category_id
- category_name
event_cat_relation
- er_cat_id
- event_id
- event_category_id
To populate an html select box, I'd like to query for event_id and event_name. I can use the following sql to get the data, but duplicates are persistent. Despite numerous variations of the sql, I cannot remove the dupes.
SQL
=============
select e.event_id, t.name
from event e, event_type t, event_cat_relation r
where e.event_type_id = t.event_type_id and e.event_id = r.event_id
order by t.name
RESULTSET
=============
EVENT_ID NAME
1567 Exercise and the Personality
1567 Exercise and the Personality
1567 Exercise and the Personality
1227 Expectant Fathers
1227 Expectant Fathers
1232 Expectant Grandparents
1231 Expectant Grandparents
1579 Health Insurance: Am I Covered?
1579 Health Insurance: Am I Covered?
1213 Health on the Net
1573 Heart Failure Prevention and Treatment
1573 Heart Failure Prevention and Treatment
Thanks for any help.
michael
