EDIT: Problem solved. It was my reading that was incorrect, not the SQL :p
Hi!
I was just reading in my database book about the LIKE SQL statement. It said this:
SELECT whatever FROM whereever WHERE 'Jeff' LIKE 'Jeff';
It continued to say that the statement ‘Jeff’ LIKE ‘Jeff’ would always return false. The book did not tell me why, nor can I find this anywhere else. Does this then mean that the following SQL also would return null?
SELECT W.name FROM whereever W WHERE w.name LIKE 'Jeff';
For reference, the book is:
Database Management Systems: Ramakrishnan – Gehrke From McGRAW – Hill. International edition. ISBN 0-07-123151-X PAGE 140.
I took a look at that page (Amazon "search inside this book") and the key thing that you’re missing is that the author is making a point there about whitespace. The book actually says
Note the spaces!
Just to make it clear why the mistake occurred, here’s the text:
Since the space is at the end of the line, it’s hard to see. But as I say below, the quote mark wouldn’t wrap to the next line if there were no space there.