Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 13th, 2003, 10:25 AM
zdr zdr is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 6 zdr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
table organization and sql query

I tried several different queries but am not getting my tables to work so I am considering redesigning them. Basically, what I have is a db for rating CDs. Currently, it has two tables: cds and ratings.

cds table has the primary key cdId, along with other stuff about the cd. ratings table has the userId, the cdId they voted on, and what they voted on it (number between 1-10).

That said, I want to produce an SQL that will show the cdId (and related cd info) that have NOT been voted on. Thus, it should look into the ratings table and leave the ones that have been voted on and show everything else from cds table. That way, when a cd has been voted on, it wont' show up next time.

Is there a better approach than this on creating the table? And if not, how should I do the sql? This SQL function is being embedded into an ASP file so I'm getting stuck on both the SQL and ASP parts. Thanks!

Reply With Quote
  #2  
Old February 13th, 2003, 10:56 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,762 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 4 h 29 m 45 sec
Reputation Power: 37
The table layout sounds okay.

To get all CDs that have not been voted on

Code:
select * from cds
 where cdid not in (select cdid from ratings)

Reply With Quote
  #3  
Old February 13th, 2003, 11:06 AM
zdr zdr is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 6 zdr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thank you so much! it works beautifully and you made it look so simple! for the life of me, i kept trying INNER JOIN, LEFT JOIN, and completely overlooked NOT IN. again, thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > table organization and sql query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway