you are getting a
cross join effect
you have not restricted which rows of the actor table should be matched up with which rows of the director table, so every row of the actor table is paired with every row of the director table, and then only those rows which meet the WHERE criteria are retained
i'm going to make a guess and say that you don't want a join, you want a union
what you probably want is something like this:
Code:
select sum(cost) as value
from (
select cost
from actor
where actor_id
in ( 1, 2, 3, 9 )
union all
select cost
from director
where director_id = 1
)
unfortunately, mysql doesn't do UNION until 4.0, and doesn't do derived tables until 4.1
so you will probably have to run two queries:
Code:
select sum(cost) as value
from actor
where actor_id
in ( 1, 2, 3, 9 )
select sum(cost) as value
from director
where director_id = 1
and add up the two costs yourself