We can use variables on Mysql server to enhanced our queries and let the server work by us
primero debemos declararlas antes de usarlas
despues podemos hacer uso de esas variable dentro de nuestras consultas
First, should declare variables before use it
after we can use inside query
SET @VariableName:=Value, @VariableName:=Value,...
ejemplo/sample
oServer:Execute( "set @balance:=0, @val1:=20, @val2:=100" )
oQry = oServer:Query( "select credit, debit, @balance:=@balance+credit-debit as balance, @val1, @VAL2 from test" )
Download Test
podemos ver come el query retorna en una de sus columnas el saldo acumulado de cada fila
we can see, the query return a total balance by row
No hay comentarios:
Publicar un comentario