Netstar
|
| Posted: 04/09/2003, 11:59 AM |
|
using a search form populated by a database (one table) which uses dropdown list to show catagories. some of the listing are repeated on the drop down list. how to I make the dropdown list only show distinct listing only.
view project hrer: http://ads-homebusiness.com/reader/search.php
or how can I add the following for the dropdown
list SQL statement
SELECT DISTINCH catagories
FROM catagories
|
|
|
 |
RonB
|
| Posted: 04/10/2003, 6:50 AM |
|
First off, why would you store the same category more then once in the categories table? The problem now is you have to select two fields for the dropdown. If you use the primarykey and the category text distinct will still result in showing the same category twice.
prim text
1 blue
2 red
3 blue
the distinct part will look at the entire row so blue will show twice even with using distinct because"
1 blue
3 blue
look different to the database server.
There are two ways of working around this problem:
1 use the same field as key and text => select distinct cat_desc from categories
set bound and text column to cat_desc. In the result grid alter the url parameter to accept cat_desc as a text parameter.
2. Be smart and do not enter the same info twice in a table when you can avoid it. alter the table categories and make sure categories exist only once in your categories table. In my example table that would mean deleting 3 blue. Now update the tables using the categories so entries that had 3 blue will be updated to 1 blue. After that you can use select cat_id, cat_desc from categories as sql fro the drop down setting bound to cat_id and text to cat_desc.
Ron
|
|
|
 |
|