选择查询sql问题 [英] Select query sql question
本文介绍了选择查询sql问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的桌子
例1
用户|状态|单位|日期
1 | 0 | 1 | 2015-01-01
1 | 2 | 2 | 2015-01-01
例2
用户|状态|单位|日期
1 | 2 | 1 | 2015-01-01
1 | 2 | 2 | 2015-01-01
如果这是真的我只想要一个结果
(当用户= 1且状态= 2且数据= 2015-01-01时)
示例1应该给我0条记录
示例2应该给我1条记录
This is my table
example 1
user | status | unit | date
1 | 0 | 1 | 2015-01-01
1 | 2 | 2 | 2015-01-01
example 2
user | status | unit | date
1 | 2 | 1 | 2015-01-01
1 | 2 | 2 | 2015-01-01
I only want a result when this is true
(When user = 1 and status = 2 and datum = 2015-01-01)
example 1 should give me 0 records
example 2 should give me 1 record
推荐答案
Assuming that the columns user, status and unit are int , the following should give you wanted.
SELECT *
FROM your_table
WHERE user=1 AND
status=2 AND
unit=1 AND
[date] = '2015-01-01'
这篇关于选择查询sql问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文