sql获取列具有特定值的所有行 [英] sql get all rows where column has certain value

查看:304
本文介绍了sql获取列具有特定值的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天伙计



我有一张桌子

有两列



订单和状态



订单可以多次包含相同的订单号

状态可以包含1到9



我想选择状态为8但状态不是9的所有订单



任何帮助都是赞赏



亲切的问候

Good day Guys

I have a table
with two columns

order and status

order can contain the same order number multiple times
status can contain 1 to 9

I want to select all the orders which have a status of 8 but not a status of 9

Any assistance would be appreciated

Kind regards

推荐答案

试试这样,正如我在评论中告诉你的,

如果您需要status = 8的记录:

Try like this,As i told you in my comments,
If you need records having status=8:
select order,status from Table_Name where status=8





或1到8的记录:



Or Records from 1 to 8 :

select order,status from Table_Name where status<=8


对不起,我似乎很难解释自己英语是不是我的第一语言我必须返回o1和o3,因为o2的状态为9





Sorry I seem to have difficulty explaining myself English is not my first language I have to return o1 and o3 as o2 has a status of 9


引用:

ColOrder Colstatus

o1 1

o1 2

o1 3

o1 4

o1 5

o1 6

o1 7

o1 8

o2 1

o2 2

o2 3

o2 4

o2 5

o2 6

o2 7

o2 8

o2 9

o3 1

o3 2

o3 3

o3 4

o3 5

o3 6

o3 7

o3 8

ColOrder Colstatus
o1 1
o1 2
o1 3
o1 4
o1 5
o1 6
o1 7
o1 8
o2 1
o2 2
o2 3
o2 4
o2 5
o2 6
o2 7
o2 8
o2 9
o3 1
o3 2
o3 3
o3 4
o3 5
o3 6
o3 7
o3 8







亲切的问候




Kind regards


这篇关于sql获取列具有特定值的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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