4 hours trying to do this query

This is a discussion on "4 hours trying to do this query" within the Databases section. This forum, and the thread "4 hours trying to do this query are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 31st, 2007, 12:49
Junior Member
Join Date: Jul 2007
Location: England
Age: 24
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
4 hours trying to do this query

Hi, i have spent too long on this now and am getting no where. im going to take a break and come back to it again soon. but just incase someone out there can do this in their sleep i thought i would plea for help...

I have 3 tables.

clubs
--------
cID
cName
cInfo

sponsors
--------
sID
sName
sInfo

club_sponsors
---------
cID
sID


club_sponsors stores which sponsor shows up in which club. What i am trying to do is create a query that will display all the clubs excluding clubs that a perticular sponsor has already been added to.

Any help is much appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 31st, 2007, 16:07
Junior Member
Join Date: Jul 2007
Location: England
Age: 24
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Re: 4 hours trying to do this query

Done it, for those that want to know:

SELECT cID, cName
FROM clubs
WHERE (cID NOT IN
(SELECT cID
FROM (SELECT club_sponsors.cID, club_sponsors.sID
FROM (clubs clubs_1 INNER JOIN
club_sponsors ON clubs_1.cID = club_sponsors.cID)
WHERE (club_sponsors.sID = @sID)) derivedtbl_1))
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
exclude, query, sql

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How many hours does it take you to design a web site? tox0tes Webforumz Cafe 8 Sep 13th, 2007 17:54
query about my $query ziggi PHP Forum 9 Aug 10th, 2007 14:05
MySQL query query dangergeek Databases 3 Apr 12th, 2007 12:45
Hosting off peak hours question RealMetrics Hosting & Domains 8 Aug 15th, 2006 18:38
Hours wasted - help desperately sought after crimsone Graphics and 3D 7 Nov 6th, 2005 16:45


All times are GMT. The time now is 11:49.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42