Print Page | Close Window

Needs Help With SQL Query

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=17259
Printed Date: 29 March 2026 at 12:52pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Needs Help With SQL Query
Posted By: Misty
Subject: Needs Help With SQL Query
Date Posted: 15 November 2005 at 12:07am
Can someone please help me with the following SQL Query:
 
select City from Advertiser, AdvertiserSubCategory, City
where Advertiser.CityID=City.CityID
and Advertiser.AdvertiserID=AdvertiserSubCategory.AdvertiserID
and SubCategoryID = 8
and Approve=1
Order By City
 
It works fine, but I don't like the fact that it returns a certain city more than once. I'd like for it to only return a city one time. There are two records under SubCategoryID. How would I accomplish this?



Replies:
Posted By: michael
Date Posted: 15 November 2005 at 1:40pm
Not knowing what your schema looks like, but I would do a join between the tables. Then depending on the keys you may need to make a left join so city comes out only once.....
If that does not help post your table schema, should be easy to do.


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: theSCIENTIST
Date Posted: 15 November 2005 at 6:34pm
Either that, or do a SELECT DISTINCT ... that would return only distinct records.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com



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