Hello,
I am getting a bit confused regarding apostrophes in my SQL statement. I can get it to work but I would like to understand why it works when it does or, conversely, why it doesn't work when it doesn't. If you know what I mean. Anyway - here goes:
This doesn't work and it produces an error:
SELECT detail FROM options WHERE option = 'site name'
This doesn't work but simply returns an empty data set:
SELECT detail FROM options WHERE 'option' = 'site name'
This does work:
SELECT detail FROM options WHERE option = 'site name'
I am having trouble getting the correct apostrophe into the above code - option should be encased in the same apostrophe that seems to delineate inline code and I can't figure out how to escape it.
As you can see the difference is all about the apostrophes.
Any explanation would be most welcome, thank you.
Simon.
This is just me trying to figure out how to escape the apostrophe:SELECT detail FROM options WHERE ``option`` = 'site name'