sql语句和查询 [英] sql statement and query

查看:65
本文介绍了sql语句和查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子,例如:

id项目descr其他
1个abc d
2 b abc e
3 c def f


现在我正在尝试通过
将desc放在下拉列表中
SELECT DISTINCT ID,descr
FROM tablex

问题是我希望如果有多个描述,它只会显示一次.我以为不同的人会那样做,但是ID肯定不一样,所以看不到它们是一样的,这就是为什么它们都被显示出来的原因.

i have a table ex:

id item descr other
1 a abc d
2 b abc e
3 c def f


now i am trying to put the desc in a drop down list, by doing

SELECT DISTINCT id, descr
FROM tablex

the problem is that i would like that if there are multiple descr it will be shown only once. i thought the distinct would do that but of course the id is not the same so it is not seeing it as the same that''s why they are both being displayed. What and how should i do it please?

推荐答案

SELECT DISTINCT descr
FROM tablex


当您只想显示descr时不需要ID.


You do not need the id when you want to show the descr only.


可能最简单的方法是使最终描述唯一化

喜欢

SELECT DISTINCT id,descr和其他
从tablex


或者您可以使自己与众不同,然后在Submit事件中检查是否仅找到一个id,如果没有,则填充第二个dropdoen以在"d"和"e"之间进行选择
may be the easiest thing is to make the final description unique

like

SELECT DISTINCT id, descr + other
FROM tablex


or you can make your distinct and then on the submit event you check if you find only an id, and if not populate a second dropdoen to choose between "d" and "e"


这篇关于sql语句和查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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