i have 3 tables: offers, rewards, and sources. sources has just a source
name and source id. both the offers and rewards tables have a "source_id"
field which relates to the sources table. i need to write a query that
selects the source name and the count in each table with that source id. is
this possible? i tried:

select s.source_name, count(o.source_id) as offer_count, count(r.source_id)
as reward_count from sources as s, offers as o, rewards as r where
s.source_id = o.source_id and s.source_id = r.source_id group by s.source_id
order by s.source_name;

the "AND" makes it produce no results. so i tried:

select s.source_name, count(o.source_id) as offer_count, count(r.source_id)
as reward_count from sources as s, offers as o, rewards as r where
s.source_id = o.source_id or s.source_id = r.source_id group by s.source_id
order by s.source_name;

notice the "or" instead of "and"...this produces invalid results. someone
help please!  =)

TIA,

Daren Cotter


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to