944,147 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 770
  • MySQL RSS
Nov 5th, 2009
0

exclude

Expand Post »
hi

i have two tables, one is products, the other is for 'discounts' on those products... when adding a new 'discount' i want to avoid adding two discounts to a single product... so i was looking for some sort of Right Join which would exclude all products which have a match in the discount table?!

Ill be using a 'select' to choose a product to add a discount to... the query needs to output all product name without a corresponding discount entry...

any ideas?

lworks
Similar Threads
Reputation Points: 15
Solved Threads: 2
Junior Poster
lifeworks is offline Offline
145 posts
since Nov 2007
Nov 5th, 2009
2
Re: exclude
Something like this:
MySQL Syntax (Toggle Plain Text)
  1. SELECT * FROM product WHERE id NOT IN (SELECT product_id FROM discount)
Sponsor
Featured Poster
Reputation Points: 557
Solved Threads: 735
Bite my shiny metal ass!
pritaeas is offline Offline
4,204 posts
since Jul 2006
Nov 5th, 2009
0
Re: exclude
nice one! worked great.
Reputation Points: 15
Solved Threads: 2
Junior Poster
lifeworks is offline Offline
145 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Remove last chars
Next Thread in MySQL Forum Timeline: .sql file loses characters





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC