如何在我的SQL中检查相同字段的条件? [英] How to check condition for same field in my SQL?

查看:78
本文介绍了如何在我的SQL中检查相同字段的条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,



以下是表:



Hi Team,

Following is the table:

ECNO	BRANCH	MONTH	ISDELETED
1	B1	February 2018	n
2	B3	February 2018	n
3	B3	March 2018	n
4	B1	March 2018	n
5	B2	January 2018	n
6	B3	January 2018	n





这里我们需要根据分行和开始日期和结束日期进行选择。



案例1:

如果分支是B3,开始日期和结束日期等于

根据所选分支选择。





Here we need to select according to branch and starting date and end date.

Case1:
If branch is B3, starting date and end date is equal then
pick according the branch selected.

select * from HR_BULKBILL_DETAILS where BRANCH='B3' AND MONTH='March 2018'





此查询工作正常



案例2:

如果盯着日期(假设2018年1月)和结束日期(假设2018年2月)和分支b3。如何在选择查询中检查这个条件



如何检查一个字段的两个条件?



注意: (在数据库中我们只有列Month:这个月份的例子:Januray 2018)

我正在使用我的sql。



< b>我尝试了什么:





This query works fine

Case 2:
If Staring date (Assume January 2018) and End date (Assume Febuary 2018) And Branch b3. How to check this condition in select query

How Check two condition for one field?

Note: (In database we have only column Month:this hold month- year example : Januray 2018)
I am using my sql.

What I have tried:

select * from HR_BULKBILL_DETAILS where  MONTH='February 2018' AND MONTH='March 2018' AND BRANCH='B3'

推荐答案

Finally I got result by using "between"
Following is the query:
select * from HR_BULKBILL_DETAILS where MONTH Between 'February 2018' AND 'March 2018' and BRANCH='B3'


这篇关于如何在我的SQL中检查相同字段的条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆