![]() |
| |||
| I must be doing something wrong here, but I can't for the life of me figure it out. SELECT gifts.*, count(distinct bookmarks.id) as bmcount, (select sum(have_it) from bookmarks as b1 where b1.gift_id=gifts.id) as c_count_haveit, ( (count(distinct bookmarks.id)) - (select sum(have_it) from bookmarks as b2 where b2.gift_id=gifts.id)) as c_count_wantit FROM bookmarks, gifts WHERE bookmarks.gift_id = gifts.id group by gifts.id This returns: bmcount of 1 c_count_haveit of 1 c_count_wantit of 1 But that should be impossible, as far as I can tell. The line that determines the value of c_count_wantit is just subtracting bmcount from c_count_haveit. So, shouldn't it be zero? If I replace either of the sides of the equation with 1, I get the zero I expected. So, both seem to be returning one, but when I put them together and subtract one from one - I get one! Anyone see what I'm doing wrong? Many thanks, Tom Lianza |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |