lundi 29 juin 2015

How to Use Between Clause in Sql query without using and clause

I have created a query which gets results between 2 dates, Its working fine.. Now i have a scenario in which users does not enter any date..In this case I need to fetch all the result from database regardless of date.. The following query fails when user does not enter any date, it returns empty result set.
Kindly guide me how to resolve this problem.

select * from emp_register
where date between '10-10-2015' and '15-10-2015' 
or status= 'Y'

Aucun commentaire:

Enregistrer un commentaire