On 8 Apr 2002, at 18:18, Ari B Kahn wrote:

> OK.  Now notice that insFreq has DOUBLED when used in conjunction with 
> with delFreq!
> mysql> select t1.andersonStart_pos, sum(t2.insFreq), sum(t1.delFreq) 
> from InsertionFreq t2, DeletionFreq t1 where (t2.andersonStart_pos = 
> 1072) and (t1.andersonStart_pos = 1072) group by t1.andersonStart_pos;
> +-------------------+-----------------+-----------------+
> | andersonStart_pos | sum(t2.insFreq) | sum(t1.delFreq) |
> +-------------------+-----------------+-----------------+
> |              1072 |             190 |              73 |
> +-------------------+-----------------+-----------------+
> 
> Is this a known bug?  I couldn't find anything. Or is it just my SQL?

It's your SQL.  You're not specifying any criterion for joining the 
tables, so your result set will contain every possible combination of 
a row from InsertionFreq that has andersonStart_pos = 1072 and a row 
from DeletionFreq that has andersonStart_pos = 1072.  That means if 
there are 2 rows like that in DeletionFreq your insFreq sum will be 
twice what you expected.

If there's a relationship between the rows in the two tables, then 
use it to specify a join criterion.  If there's not, then leave it as 
two queries the way you did first.

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org

---------------------------------------------------------------------
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