Jump to content

use @var in mysql select query for dataset


Recommended Posts


if I want to use this query below 

select b.naam, b.voornaam,if(bu.typeid='2',bu.bedrag,0) as 'inkomst', if(bu.typeid='1',bu.bedrag,0) as 'uitgave',bu.datum,@total:= @total + if(bu.typeid=2,bu.bedrag,0) -if(bu.typeid=1,bu.bedrag,0) as 'totaal'from bewoners_uitgaven bujoin bewoners b on b.id = bu.bewonerIDjoin kl_bewoners_uitgave_type kl on kl.id = bu.typeidwhere b.Id =150;[/code]

I got null as a result for totaal, can I use @var in my mysqlstatement?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...