How to approach this SQL query

Posted by Kim on Stack Overflow See other posts from Stack Overflow or by Kim
Published on 2010-06-02T08:46:21Z Indexed on 2010/06/02 8:53 UTC
Read the original article Hit count: 257

Filed under:

I have data related as follows:

  • A table of Houses
  • A table of Boxes (with an FK back into Houses)
  • A table of Things_in_boxes (with an FK back to Boxes)
  • A table of Owners (with an FK back into Houses)

In a nutshell, a House has many Boxes, and each Box has many Things in it. In addition, each House has many Owners.

If I know two Owners (say Peter and Paul), how can I list all the Things that are in the Boxes that are in the Houses owned by these guys?

Also, I'd like to master this SQL stuff. Can anyone recommend a good book/resource? (I'm using MySQL).

Thanks!

© Stack Overflow or respective owner

Related posts about mysql