Reputation: 11
I have a column in my database that is entitled area and when users register they pick an area from 6 options. When I try to setup a search that shows people from those areas using a dropdown menu it duplicates them and only shows one result when the form is submitted.
SELECT * FROM registration ORDER BY area
is my query and in the dropdown it produces results like:
Warwickshire
Warwickshire
Warwickshire
Northamptonshire
etc. but I want it to just show Warwickshire once and when you click submit it shows all the people from Warwickshire instead of just the one user.
Any help is appreciated, thanks Richard.
Upvotes: 1
Views: 4022
Reputation: 77926
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;
Upvotes: 1
Reputation: 6192
try this
"SELECT * FROM registration GROUP BY <repeating_column_name> ORDER BY area"
Upvotes: 3