SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple table query

    Hi, I have some troubles with select from multiple tables. There are 3 tables - books (id, name), borrow_log(id_book, id_user), users(id, name). All i want to do is select books that havent been borrowed by specific user (e.g. "John"). I wonder if it could be done w/o subqueries?
    Thanks in advance.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,268
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    yes it can

    however, we don't just hand out homework answers on this site, we make you figure it out

    what you want is a LEFT OUTER JOIN, in which you try to find the books john has borrowed, and test for NULL in the WHERE clause, to find the ones he hasn't

    that's a bigger hint than healdem gave you
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot, im just a bit confused thinking about it for a couple o hours....and man. pages werent the right thing to solve it for me


Bookmarks

Posting Permissions

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