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

Stop duplicates in table?

Guest
Oct 22, 2010 Oct 22, 2010

Copy link to clipboard

Copied

Hi

I have just starting using asp pages and need som advise on how to stop duplicates showing within a table.

I know it's something required in the sql recordset, but don't know what.

Here is what I already have -

SELECT DISTINCT txtTown, txtPropertyURL
FROM Cheshire

What I need is the Town to show in the table without duplicates, but be able to link the url to each town name.

Any pointers would help.

Many thanks.

TOPICS
Server side applications

Views

447
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
Participant ,
Oct 22, 2010 Oct 22, 2010

Copy link to clipboard

Copied

when using DISTINCT, you are looking for a unique value of the column you list in the SELECT statement so SELECT DISTINCT txtTown, txtPropertyURL means give me the records that have a unique txtTown and txtPropertyURL combination. if you are getting duplicates in your result set, it means you have different URL values for 1 town. for example...

txtTown                    txtPropertyURL

Los Angeles               www.url1.com

Los Angeles               www.url2.com

even though Los Angeles is the same town, because the URL is different in more than 1 record it will show up more than once. check the records in your database to see if this is happening. you can also prevent duplicates in the database by using unique indexes. here are some links to help you out

DISTINCT sql query http://www.sql-tutorial.com/sql-distinct-sql-tutorial/

UNIQUE INDEXES in MSSQL http://msdn.microsoft.com/en-us/library/ms175132.aspx

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
LEGEND ,
Oct 22, 2010 Oct 22, 2010

Copy link to clipboard

Copied

>I know it's something required in

>the sql recordset, but don't know what.

No, it's really not. As w1n78 already explained, if you have multiple urls for each town then your results are going to have duplicate town's. If you are trying to supress the output of the duplicate town name, then look for an option in the repeating region to supress duplicate names. They'll still be in the recordset but won't be output to the screen. Is that what you are after?

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
Guest
Oct 22, 2010 Oct 22, 2010

Copy link to clipboard

Copied

LATEST

Hi Guys

Many thanks for the feedback.

I can see now that the duplicate town would show as the url is different, should have seen that as it's pretty obvious.

However, I do need to know how to supress the output of the duplicate town name by using the repeating region.

Thanks again

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