I suspect you want 'IS NULL' rather than '= NULL'. :)

I always find it best to think of NULL as "undefined value" rather than "no
value" - which is why you need to check for it especially (using IS rather
than = or other operators).


Cheers,


Matt

> -----Original Message-----
> From: Yonah Russ [mailto:[EMAIL PROTECTED]
> Sent: 21 April 2004 14:47
> To: MySQL List
> Subject: Re: query help
> 
> I got a response off the list suggesting writing a function to go over
> the query results- it's not hard but I'd rather do this in sql if
> possible.
> 
> I came up with this:
> select books.bookid,books.title,copies.copyid from books left join
> copies on books.bookid=copies.bookid where copies.copyid=NULL;
> 
> this didn't work even though without the where clause I got exactly what
> I wanted- the left join filled in the entries that didn't have copies
> with a null copyid.
> 
> what did I do wrong?
> thanks
> yonah
> 
> Yonah Russ wrote:
> 
> > Hi,
> > I have two tables- books and copies
> >
> > every book has an id in the books table
> > every copy of a book has the books id and a copy id in the copies
> > table (1 row per copy)
> >
> > I want a list of all the books that don't have any copies meaning all
> > the book id's in books that don't match any book id's in copies.
> >
> > how can I do this?
> > thanks
> > yonah
> >
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to