Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql IN statement to be always true

Tags:

sql

sql-server

i have the following sql query

select * from tblArea where AreaDescription in ('Processing1','Geology 66','Site Infrastructure')

currently it shows the records where AreaDescription in ('Processing1','Geology 66','Site Infrastructure')

but i need to pass value to in query which will be always true and show all the records.i know that i can use where clause

where 1=1

but here i need to use the in statement.is it possible?

like image 303
chamara Avatar asked Oct 05 '12 07:10

chamara


1 Answers

I don't understand why you need it and why you don't want to add where 1=1 or omit the WHERE, but you could do it this way:

select * from tblArea 
where AreaDescription in 
(AreaDescription,'Processing1','Geology 66','Site Infrastructure')

Test: http://sqlfiddle.com/#!3/6e15d/1/0

like image 106
Tim Schmelter Avatar answered Sep 20 '22 16:09

Tim Schmelter