Make a search filter

180 Views Asked by At

I have 5 fields in database. Query where clause has 5 parameters.

now if I pass no parameter it should retrieve all records. If I pass only 2nd parameter it retrieves based on that parameter. but if I pass 2nd and any parameter after that it only takes 2nd parameter, it not uses the parameter after 2nd parameter. I am using or operator:

query

select address from table1 where state ='' or city ='Aa' or address_line ='school'

it should retrieve all records that has City = Ab and address_line = school. But it retrieves based on city , it not uses the address_line.

1

There are 1 best solutions below

2
On

I think you have to chance the second OR to a AND for it to pick also the second parameter

And you litteraly said it in your explanation "and" so why stil write or.