My Sql Full Outer Join not working
I would like to know the alternative for Full Outer Join in MySQL. I know
it can be done through union but it's not working because my requirement
is little complex I hope so. I have two tables
master(id,mindate,billvalue) and transfer(id,maxdate,travalue) in which
both id fields will be almost same. Now I need to get the values
id,sum(billvalue),sum(travalue) by joining two tables with the conditions
Mindate=current date
Maxdate=current date
If master's table doesn't have any value but transfer table contains then
transfer's value must be included
If master's table contains value but transfer doesn't then master's value
must be displayed.
I tried union, join, etc, but nothing helped I know I am doing something
wrong somewhere but I can't identify that please help me with this.
I used the below query,
select master.id, sum(billvalue) as billvalue, sum(travalue) from
master join transfer on master.id=transfer.id join where
mindate=CURDATE() and maxdate=CURDATE() group by id
No comments:
Post a Comment