本文介绍了从sql查询中选择唯一的联系人no,不要检查其他列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
cmd = new OleDbCommand("Select distinct contactno,cust_name from table1",con);
我正在使用上面的查询但是当contactno和 cust_name
都相同时,它会检索唯一的记录。我想只使用contactno放置distinct关键字,以便它根据contactno检索记录而不检查 cust_name
。
I am using query like above but it retrieve unique records when both contactno and cust_name
are same.. I want to put distinct keyword only with contactno so that it retrieve records based on contactno and dont check cust_name
.
推荐答案
cmd = new OleDbCommand("select contactno,cust_name from table1 group by contactno,cust_name having count(distinct contactno)=1",con)
但是如果你想删除重复的ContactNo和cust_Name,你可以使用它作为
but if you want to remove duplicated ContactNo and cust_Name you can use it as
cmd = new OleDbCommand("select contactno,cust_name from table1 group by contactno,cust_name having count(contactno)=1",con);
cmd = new OleDbCommand("Select distinct contactno from table1",con);
即表1中的不同联系人列表?
I.e. a list of the distinct contactno's that are in table 1?
这篇关于从sql查询中选择唯一的联系人no,不要检查其他列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!