Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 376475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:36:09+00:00 2026-05-12T14:36:09+00:00

I have an Classic ASP page that lets users search for properties and a

  • 0

I have an Classic ASP page that lets users search for properties and a results page that then emails the property agents who have matching properties to let them know that there are tenants interested in their properties.

Some agents may have more than 1 property, in which case the agent only needs to receive 1 email rather than an email for each property they have.

I have tested the following query in Management Studio and it returns the correct results;

SELECT DISTINCT CustomerEmail
FROM         (SELECT     ContentID
                       FROM          (SELECT     ContentID
                                               FROM          VWTenantPropertiesResults
                                               WHERE      (ContentStreet = '')
                                               UNION ALL
                                               SELECT     ContentID
                                               FROM         VWTenantPropertiesResults AS VWTenantPropertiesResults_2
                                               WHERE     (ContentTown = 'Hull')
                                               UNION ALL
                                               SELECT     ContentID
                                               FROM         VWTenantPropertiesResults AS VWTenantPropertiesResults_1
                                               WHERE     (ContentPostCode = 'HU7')) AS qi
                       GROUP BY ContentID
                       HAVING      (COUNT(*) >= 2)) AS q INNER JOIN
                      VWTenantPropertiesResults AS r ON r.ContentID = q.ContentID
WHERE     (r.ContentBedRooms BETWEEN 1 AND 4) AND (r.ContentPrice BETWEEN 50 AND 500)

However, when I run the following code in the page it returns an error Incorrect syntax near the keyword ‘SELECT’;

rsemailagents.Source = "SELECT DISTINCT CustomerEmail"
rsemailagents.Source = rsemailagents.Source& "FROM    ("
rsemailagents.Source = rsemailagents.Source& "        SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "        FROM    ("
rsemailagents.Source = rsemailagents.Source& "                SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "                FROM    VWTenantPropertiesResults"
rsemailagents.Source = rsemailagents.Source& "                WHERE   ContentStreet = '" & Replace(rspropertyresults__varReqStreet, "'", "''") & "'"
rsemailagents.Source = rsemailagents.Source& "                UNION ALL"
rsemailagents.Source = rsemailagents.Source& "                SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "                FROM    VWTenantPropertiesResults"
rsemailagents.Source = rsemailagents.Source& "                WHERE   ContentTown = '" & Replace(rspropertyresults__varReqTown, "'", "''") & "'"
rsemailagents.Source = rsemailagents.Source& "                UNION ALL"
rsemailagents.Source = rsemailagents.Source& "                SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "                FROM    VWTenantPropertiesResults"
rsemailagents.Source = rsemailagents.Source& "                WHERE   ContentTrimmedPostCode LIKE '" & Replace(varPostcode, "'", "''") & "%'"
rsemailagents.Source = rsemailagents.Source& "                ) qi"
rsemailagents.Source = rsemailagents.Source& "        GROUP BY"
rsemailagents.Source = rsemailagents.Source& "                ContentID"
rsemailagents.Source = rsemailagents.Source& "        HAVING  COUNT(*) >= 2"
rsemailagents.Source = rsemailagents.Source& "        ) q "
rsemailagents.Source = rsemailagents.Source& "JOIN    VWTenantPropertiesResults r "
rsemailagents.Source = rsemailagents.Source& "ON      r.ContentID = q.ContentID "
rsemailagents.Source = rsemailagents.Source& "WHERE   ContentBedrooms BETWEEN " & Replace(rspropertyresults__varBedroomsNoMin, "'", "''") & " "
rsemailagents.Source = rsemailagents.Source& "AND     " & Replace(rspropertyresults__varBedroomsNoMax, "'", "''") & " "
rsemailagents.Source = rsemailagents.Source& "AND     ContentPrice BETWEEN " & Replace(rspropertyresults__varPriceMin, "'", "''") & " "
rsemailagents.Source = rsemailagents.Source& "AND     " & Replace(rspropertyresults__varPriceMax, "'", "''") & " " & varSQL & " "

I wondered if anyone has any ideas on why the DISTINCT won’t work in the code?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:36:10+00:00Added an answer on May 12, 2026 at 2:36 pm

    Put a space in the string at the end of this line

    change

    rsemailagents.Source = "SELECT DISTINCT CustomerEmail"
    

    to this

    rsemailagents.Source = "SELECT DISTINCT CustomerEmail "
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Classic ASP page that lets users search for properties and a
NET and VB.net code behind. I have a classic ASP page that connects to
I have a SQL interface page in my classic ASP web app that allows
I have a classic ASP page that requires two values from a form. These
I have a classic ASP page that calls in some other ASP files using
I have some code on a classic ASP page that is attempting to get
I've got a fairly complex classic asp page that for some users doesn't render
We have a classic ASP page that is instantiating a .Net object through a
I have a classic ASP page that is setting the ContentType to text/plain and
I have a classic ASP page that was implemented in 2002-ish. It was acting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.