Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

"There Exists"?

I was wondering if there is a way to do a "there exists" in SQL. The application looks kind of like a library. I have a table of books, and a table of the logs (when things were checked in and out and by whom). A book is currently checked out if there exists an entry in the log which has a NULL in the returned field, otherwise, it is checked in. Is there a way to implement this in a query that would get all of the books and whether they are checked in or not, or would it be better to just store an extra bit-field in the book table which is a status bit?

Thanks.
[576 byte] By [evlich] at [2007-11-11 10:18:28]
# 1 Re: "There Exists"?
What kind of database is it (Access, SQL Server, MySQL, etc.)?
Phil Weber at 2007-11-11 23:43:25 >
# 2 Re: "There Exists"?
It is a mySQL database.
evlich at 2007-11-11 23:44:25 >
# 3 Re: "There Exists"?
MySQL EXISTS ( http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html)
aniseed at 2007-11-11 23:45:24 >
# 4 Re: "There Exists"?
Thank you very much.
evlich at 2007-11-11 23:46:26 >