Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

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 Codewalkers Forums Sponsor:
  #1  
Old November 18th, 2003, 08:01 PM
NESA NESA is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Portland, ME USA
Posts: 10 NESA User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Can an intermediate table exclude records in a join?

Using MySQL, I would like to select records from a table (Products w/ the field ProductNumber) and join all records from another table (Features w/ the field FeatureNumber) unless those feature records appear in a third table (Exclude w/ the fields ProductNumber, FeatureNumber) Is this possible, and what would be the appropriate syntax.

Reply With Quote
  #2  
Old November 18th, 2003, 08:26 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Can an intermediate table exclude records in a join?

The easiest way I can think of is to left join to the table that excludes rows and then use 'having field is null' at the end. This will only keep rows that didn't match the third table.

Sorry I can't tell you more, can't stay today.

Reply With Quote
  #3  
Old November 18th, 2003, 09:35 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Can an intermediate table exclude records in a join?

I think vertigo has the right idea, but HAVING statements are only usful for GROUP BY clauses. Try something like this:
Code:
SELECT * FROM
features AS f
INNER JOIN products AS p ON f.product_number=p.product_number
LEFT JOIN exclude AS e ON e.product_number=f.product_number AND e.feature_number=f.feature_number
WHERE e.feature_number IS NULL

Reply With Quote
  #4  
Old November 19th, 2003, 07:45 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Can an intermediate table exclude records in a join?

Honcho's is better, rather leave 'having' for when you need to use it.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Can an intermediate table exclude records in a join?


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 1 hosted by Hostway
Stay green...Green IT