Forum Moderators: open

Message Too Old, No Replies

Using SELECT DISTINCT

Problem with hidng duplicate entries in results

         

gandalf12

8:30 pm on Apr 10, 2007 (gmt 0)

10+ Year Member



I have a database table of customers, the cust_id is the primary key and is an autonumber field. The other fields are name address town county etc.
I wish to have a page on my site with dynamic linked dropdown boxes as follows Box 1 would show all the counties listed in the database, when one is selected Box 2 would show the towns listed in the database for that county and when one is selected Box 3 would show all the customers listed in the database.
The problem I have is that when attempting to write an sql to achieve this, I have been unable to remove duplicate entries, so if i have 10 customers in a county I get 10 names of the county listed and the same for towns.
Is this possible to code?

LifeinAsia

8:34 pm on Apr 10, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Why don't you post what you have so far. Plus we need other relevant details- DB, programming/scripting language, etc.

Of course it's possible to code- people have been doing it for years.

gandalf12

8:49 pm on Apr 10, 2007 (gmt 0)

10+ Year Member



I am using Access 2002 to build the database, with a Dreamweaver front end programmed in ASP.
I have attempted to code this myself but as a newbie to SQL, I can populate the first box using SELECT DISTINCT County FROM Customer .
However when I try to populate the second and I a SELECT DISTINCT statement to pull the data, I have been unable to find a way of only pulling the towns relating to the chosen county.
I attempted to do this using a Macromedia extension (Kermy 7803 Dynamic DDL from [kermy.com...] but as you have to SELECT 2 fields I can no longer use DISTINCT to hide the duplicates.

Thanks

phranque

9:09 pm on Apr 10, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you probably want to use "GROUP BY"...

gandalf12

9:23 pm on Apr 10, 2007 (gmt 0)

10+ Year Member



I would agree that I can use GROUP BY to sort and hide the duplicates, but as far as I can see this will work for a single Box but not allow me to populate a Box dependent on the selection in the previous Box