Thread: Help in query

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    1
    Rep Power
    0

    Help in query


    how would you select all customers who bought product 'a' but did not buy products 'b', Without using subselects. (make sure there are no customers bought product 'b' in the result.)
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    This sounds like homework.

    Anyway, this is much too vague to give a concrete answer. In PostgreSQL, you might first select the customers with either product 'a' or 'b' and then use the "boolean_and" aggregate function to get the products with only 'a'.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,212
    Rep Power
    4279
    Originally Posted by Ranvir
    Without using subselects.
    your teacher is cruel, but there is a specific point

    we won't help you until you post your best effort for this assignment

    by the way, is there a specific target database system, or is this a pure SQL question?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo