我想从sqlserver中的表中获取具有不同值的表id [英] I wanna get the table id with distinct values from table in sqlserver

查看:162
本文介绍了我想从sqlserver中的表中获取具有不同值的表id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从sqlserver中的表中获取带有不同值的表id





i使用此查询



从表名中选择distinct(id,columname1,columnname2)



但是我得到了所有值,因为id是auto增量值

I wanna get the table id with distinct values from table in sqlserver


i was used this query

Select distinct(id,columname1,columnname2) from table name

but i got all all values,because the id is auto increment value

推荐答案

使用distinct获取所有值没有意义。

如果获得所有不同的值,则获得一个表示不同值的值。



因此返回id没有意义。



如果你想要所有id为id的值,返回由id排序的所有值。
Getting all values using distinct does not make sense.
If you are getting all distinct values, you are getting one single value representing distinct values.

Thus returning the id does not make sense.

If you want all values with id's, return all values ordered by ids.


这篇关于我想从sqlserver中的表中获取具有不同值的表id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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