Print Page | Close Window

Needs Help With SQL Query Results

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=17400
Printed Date: 29 March 2026 at 4:24pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Needs Help With SQL Query Results
Posted By: Misty
Subject: Needs Help With SQL Query Results
Date Posted: 29 November 2005 at 9:37pm
I am having a problem with a sql query. I'd like for it to only show one listing under an advertiserID even if it has multiple subcategories.
 
Here's my code:
mySQL = "Select distinct listingtype, businessname, advertisersubcategory.advertiserid, contactperson, address, category, city, state, zip, phone, fax, tollphone, cellphone, subcategoryid, website, showemail, email From Advertiser, AdvertiserSubCategory, Categories, County, City"
 mySQL = mySQL & " where Advertiser.AdvertiserID = AdvertiserSubCategory.AdvertiserID"
 mySQL = mySQL & " and Advertiser.CategoryID = Categories.CategoryID"
 mySQL = mySQL & " and Advertiser.CountyID=County.CountyID"
    mySQL = mySQL & " and Advertiser.CityID = City.CityID"
    mySQL = mySQL & " and Advertiser.CountyID = '" & strCountyID & "'"
    mySQL = mySQL & " and Advertiser.CategoryID = 8" 
 mySQL = mySQL & " and Approve =1"
 mySQL = mySQL & " Order By ListingType, BusinessName"


The query only returned two listings when I removed subcategoryid, but I really need it to be in this query. It shows three listings with the subcategoryid field. Here's the table schema:

businesssname:        subcategoryid:      advertiserid:
Test Real Estate          13                &n bsp;         26
Sample Real Estate      13         &n bsp;               31
Sample Real Estate       56                &n bsp;       31

I would like for Sample Real Estate to only show up one time with the subcategoryid field. How do I get this to work? I need the subcategoryid field because it is being used in an important link for this listing.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net