Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Needs Help With SQL Query
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Needs Help With SQL Query

 Post Reply Post Reply
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: Needs Help With SQL Query
    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?
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2005 at 6:34pm
Either that, or do a SELECT DISTINCT ... that would return only distinct records.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.