Get one or all records from the table based on condition in where clause using BOOLEAN LOGIC rather than CASE or IF statement. Click on the link to read complete post.
Read this post on techiners.blogspot.com