Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    1

    Post Unanswered: Need to get records from first table

    I have two tables user_registration and user_subscription, first users get registers on the site and information goes into first table user_registration. Secondly users are made paid subscribers and the information goes into 2nd table user_susbscriptions.

    Now i need a MySql query to fetch emails etc from table 1 who are just registered users not subscribed. How i can exclude the users who are subscribed and their user id exist in table 2. user id is foreign key in table 2.
    How i can fetch the emails from table 1 who are just registers not subscribed. Please help me to make a query.

    Thanks,
    Shahnawaz

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    use a LEFT OUTER JOIN together with an IS NULL check on the joined column of the right table (to find the unmatched rows of the left table)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    Or a NOT EXISTS/NOT IN subquery.

    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •