moviehay0032
moviehay0032

Reputation: 23

Query with number after GROUP BY

I have a query to get data like this : .....

WHERE  ((column1=1 OR column1=3) AND
        (column2= 0 or column2= 4)
       ) AND (1)
GROUP BY 1,(2)

I don't know the meaning of "AND (1) GROUP BY 1,(2)" does anyone can explain it? , thank you

Upvotes: 1

Views: 99

Answers (1)

DavidG
DavidG

Reputation: 119017

Let's format the query a little, that should help clear it up:

WHERE ((column1=1 OR column1=3) 
AND (column2= 0 or column2= 4) ) 
AND (1) 
GROUP BY 1,(2)

So the AND (1) part is the same as saying AND (true) or AND (1=1). It always returns true so is effectively doing nothing.

The GROUP BY is just using the column position of your SELECT. So it's grouping byt the first column, then the second.

Upvotes: 3

Related Questions