1

我的数据库中有一个名为 area 的列,当用户注册时,他们从 6 个选项中选择一个区域。当我尝试使用下拉菜单设置显示来自这些区域的人员的搜索时,它会复制他们,并且在提交表单时只显示一个结果。

SELECT * FROM registration ORDER BY area是我的查询,在下拉列表中会产生如下结果:

Warwickshire
Warwickshire
Warwickshire
Northamptonshire

等等,但我希望它只显示一次沃里克郡,当你点击提交时,它会显示沃里克郡的所有人,而不仅仅是一个用户。

任何帮助表示赞赏,谢谢理查德。

4

3 回答 3

3

尝试这个

"SELECT * FROM registration GROUP BY <repeating_column_name> ORDER BY area" 
于 2012-05-06T14:16:44.040 回答
1

SELECT DISTINCT area FROM registration ORDER BY area

于 2012-05-06T14:17:55.577 回答
1

use distinct clause to get you the uniq data. You can' apply distinct to *; specify the particular column you are trying to get. Your case, if it's area then try

select distinct area from registration order by area;
于 2012-05-06T14:23:36.483 回答