Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

duplicates recrods from database search

New Here ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

Here is my resulting page from a selet statement

http://www.resistolhat.com/raw/retailers/locator_results.asp?select=OK&Submit=search

There are a few cities that come up more than twice, I need to only show each city once? Is there are a statement for this?

Thanks,
Fred
TOPICS
Server side applications

Views

484
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

Have you used SELECT DISTINCT?

Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
Dell stuff: http://robgt.com/dell
SatNav stuff: http://robgt.com/satnav



Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

no, I'm not sure how to use it without writing an actual select statement... I want to build it into the actual link? Is that possible?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

use the word distinct in your select statement

such as:

select distinct city_name from table where blah blah blah

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

The previsous page is here

http://www.resistolhat.com/raw/locator.asp

Can i do this while avoiding an actual select statement, can I just hard code it into the actual link?

I want the user to select the state and the results to display all of the cities from the selected state

Thank you for your time

Fred

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

Well since your database shows the entries more than once you cannot avoid using the distinct.

Have you considered normalizing your tables?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

So i guess I will need to build a select statement? I'm just not sure how to do this.

Do I bult it on the map page or the results page? I have each state linked with a image map, so I will have to build that select satement for each state?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

you could pass the state in the url to the results page

then make a dynamic select statement on the results page like so:

select distinct city_name from table_name where state = $_GET['city_variable_from_URL'];

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

Here is the orginal select statement from the resutls page....

locator_rs.Source = "SELECT * FROM Retailers WHERE State = '" + Replace(locator_rs__MMColParam, "'", "''") + "'"

Here is what I think you told me to do....



locator_rs.Source = "SELECT DISTINCT * FROM Retailers WHERE State = '$_GET['city_variable_from_URL', "'", "''") + "'"

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

well I have no idea what you are going to call your variable in the URL.

Assuming that you have an auto-incremented field in your table a select distinct * will return all the items, because no two rows can be the same.

you will need to use "select distinct field1, field2, field3 from . . . "

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

ok, I think I got it...

locator_rs.Source = "SELECT DISTINCT STATE FROM Retailers WHERE State = '$_GET['city_variable_from_URL', "'", "''") + "'"


Is everything else ok?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

more like select distinct cities from . . . .

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 20, 2006 Jun 20, 2006

Copy link to clipboard

Copied

LATEST
ok, I will keep trying. Thank you for your time.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines