Thread: Help in query

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

    Join Date
    Aug 2012
    Rep Power

    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
    Rep Power

    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
    Toronto Canada
    Rep Power
    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? | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo