variable in sql

hi,
how can I use variables inside a query

example:

select m.codpdv,
sum(if( m.idiniz_ana=’$XXX’,qta,0) ) as qta_articoli
from iniz_movfid as m
where m.idiniz_ana=‘57’
group by m.codpdv, m.codart

Just like you did it.
However, depending on where the query is fired, it might be necessary to use a global variable.
So the $XXX variable needs to be replaced with [XXX].

jsb

[QUOTE=jsbinca;40309]Just like you did it.
However, depending on where the query is fired, it might be necessary to use a global variable.
So the $XXX variable needs to be replaced with [XXX].

jsb[/QUOTE]

If you are saying so what will that global variable will be (in ou out)!!! ohoh is that not a bad idea that scriptcase offers?

That’s totally up to you.
You are the programmer and you have to take care of it, not scriptcase.
SC just gives you the tools you need.

jsb

i try with

select m.codpdv,
sum(if( m.idiniz_ana=’[xxx]’,qta,0) ) as qta_articoli
from iniz_movfid as m
where m.idiniz_ana=‘57’
group by m.codpdv, m.codart

but don’t work, work only if the variabile is in a where condition ex:

select m.codpdv,
sum(if( m.idiniz_ana=‘51’,qta,0) ) as qta_articoli
from iniz_movfid as m
where m.idiniz_ana=’[xxx]’
group by m.codpdv, m.codart

Is this in a grid or form? If it’s in a form it wouldn’t work as they need to be update aware. But in a grid it should work afaik.