Click here to Skip to main content
14,978,924 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table name "emp".I want to fetch data from the table where curr_date is today's date and sign is "ABAN".How to write two conditions in one query?
Posted
Comments
Rajesh Anuhya 22-Dec-11 2:16am
   
No effort.

See this example.
Here[^]
   
Hope you want to do this
SQL
select name,code from emp where curr_date=getdate() and sign='ABAN'
   
u should learn to solve these simple things , let it be. refer the following that might help you
http://www.databasedev.co.uk/sql-multiple-conditions.html[^]
   
If you want to search data for current date I take that you're not interested on the time portion. If the field in the database contains time you could use something like:
SQL
select  ...
from yourtable
where convert(date, curr_date) = convert(date, getdate())
and sign = 'ABAN'
   
I question does not provide fields name for your table still you can try the following concept :
SQL
Select [your desired fields separated by comma ] from emp Where (CONVERT(DATETIME,curr_date,103)=CONVERT(DATETIME,GETDATE(),103))and (sig='ABAN') 
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900