select distinct a.name,a.count1,b.count2 from gifts, (select count(g.gid) as count1,r.name from gifts g,recipients r where g.uid=1 and g.category=2 and g.rid = r.rid group by r.name)a, (select count(g.gid) as count2,r.name from gifts g,recipients r where g.uid=1 and g.category=1 and g.rid = r.rid group by r.name)b group by a.name
The main problem I am seeing, is that it is not outputing the proper counts for the same id from the two queries.. it kinda of mixes them...
select
r.name,
sum(g.category=1) as `Category 1 Total`,
sum(g.category=2) as `Category 2 Total`
from
recipients r
left join /* change to inner join if you don't want to diplay recipients without gifts */
gifts g
using(rid) /* I suppose tables are linked by rid column */
where
r.rid in(1,2) /* Jack and Jill, you can use names as well */
group by r.name /* It's safe to group by name as it have UNIQUE key over itself */