Thursday, May 21, 2015

if your'e lazy and have simple "and"s separated by "or"s

then neat "and"s and or"s work like parentheses

select * from

(
select 1 a , 'hi there' b , 102 c
union
select 2 a , 'hi there' b , 103 c
union
select 10 a , 'hi there' b , 103 c
union
select 9 a , 'hi there' b , 103 c
union
select 8 a , 'by there' b , 103 c
union
select 7 a , 'by there' b , 103 c
union
select 6 a , 'by there' b , 10 c

) as main
where b = 'by there'
and a=6
or a > 1
and a < 4
and b = 'hi there'
or a = 10

and b = 'hi there'

No comments:

Post a Comment