Working solution – Bruce Feist

  SELECT Films.idFilm, title
  FROM Films LEFT JOIN Loans
  ON (Films.idFilm = Loans.idFilm) AND (Loans.return_date IS NULL)
  WHERE Loans.idFilm IS NULL;

Note: This solution works for me as it considers that I give no value (NULL) to
the attribute return_date at the moment of borrowing a film to someone. I only
give this attribute a value when the film is returned.

Thanks a lot for proving me that my question has a solution! Finally I’ll be able to
make my program work correctly! Additionally, I will be able to prove to my
Professor that MySQL has one less limitation.

However, honestly I don’t understand why this works, and that bothers me. If it
isn’t asking too much, I appreciate it if you could explain me how LEFT JOIN
works and helps me to produce the result I wanted.

As I said, I am new to MySQL. Actually, my only experience with databases is on
a strictly theoretical level. Now I am trying to use my knowledge to create an
application for my own using MySQL and PHP, which I know is a popular
combination!

--
Remi André Mikalsen
Homepage  -  http://mikalsen.no.sapo.pt
Email          -  [EMAIL PROTECTED]


PS!
Uttam; your solution shows me which films were on loan at least once
Sam Funk; your solution shows me which films are currently on loan
Thank you anyway!

Reply via email to