Hai Friend我对Datagridview上的C#Windows和Sql Server组合有疑问 [英] Hai Friend I Have A Question On C#Windows And Sql Server Combination On Datagridview
问题描述
我有一张类似
的桌子
id status statusid complaintto
1 open 14 employee
1等待15管理
1关闭16 xyz
2开14名员工
2等待15管理
2关闭16 xyz
3开14名员工
3等待15管理
3等待15 xyz
i不想显示id关闭
将显示第3个id记录
thankx
i have a table like
id status statusid complaintto
1 open 14 employee
1 pending 15 administration
1 closed 16 xyz
2 open 14 employe
2 pending 15 administration
2 closed 16 xyz
3 open 14 employe
3 pending 15 administration
3 pending 15 xyz
i don't want to show id closed
3rd id record will be shown
thankx
推荐答案
不清楚,但是,如果您不想显示已关闭状态的记录,这样做,
Not Clear but,If you don't want to show the record with closed status,do like this,
SELECT id,status,statusid,complaintto from Table where status!='closed'
或者如果你想省略状态,那么就离开状态来自查询。
Or if you want to omit status,then just leave status from the query.
SELECT id,statusid,complaintto from Table where status!='closed'
编辑:2
你可以通过使用where子句从两个方面获得它。
2
You may get it from two way by using where clause.
select distinct a.id from #table1 as a inner join
(select id,count(id) as Count1 from #Table1 where status!='closed' group by id) as b
on a.id=b.id and b.Count1=3
或者只是这样做,
从#table1中选择id,其中statusid!= 16和ID = 3且status ='pending'和complaintto ='xyz'
Or simply do like this,
select id from #table1 where statusid!=16 and ID=3 and status='pending' and complaintto='xyz'
试试这个:
排除已关闭状态的id,然后选择其余的
你也可以使用自联接。
try this:
exclude the id which are having closed status and then select the rest
you can use self joins too.
SELECT * FROM [Sample] where id not in
(
SELECT id from [sample] where statusid = 16 -- for closed
)
这篇关于Hai Friend我对Datagridview上的C#Windows和Sql Server组合有疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!