Search Results

Search found 1 results on 1 pages for 'pablo89'.

Page 1/1 | 1 

  • Problems while trying to make a query with variables in the conditions (stored procedure)

    - by pablo89
    Hi!! Im having a problem, Im trying to do a query... I remember that in the past I did something like this but today this query is returning nothing, no error, no data, just nothing... the query is something like this: SELECT field1, @variableX:=field2 FROM table WHERE (SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=0)0 AND (SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=4)=0; I also tried this query but it didnt work (also it gaves no error): SELECT field1, @variableX:=field2, @variableY:=(SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=0), @variableZ:=(SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=4) FROM table WHERE @variableY0 AND @variableZ=0; As you can see, what Im trying to do in the 1st query is use a variable in the conditions; in the 2nd query Im trying to create some variables and evaluate them in the conditions. At the end in the 2nd query the @variableY=1 AND @variableZ=0 but I dont know what the query returns an empty data What could be wrong here??? Any comment or suggest is welcome!!! thanks!!! Bye!!!

    Read the article

1