r/learnSQL • u/MondoDuke2877 • Apr 13 '26
Single Quote Question
Hi all. Trying to learn a little about SQL and I have a question about single quotes. I know about "escaping" single quotes for something like O'Reilly by inserting 2 single quotes but I am getting syntax rejections when entering a string to retrieve specific multiple values.
Ex: I have a practice database full of practice tables. I am trying to get multiple specific values from a practice table called ServicePlans.
SELECT PlanID, PlanName, PlanDescription
FROM ServicePlans
WHERE PlanID = 'W1001' OR PlanID = 'D2002' OR PlanID = 'L2002';
This should pull up any plans with those plan IDs. But the single quotes are rejecting due to syntax error. If I go through and delete the single quotes and retype them they work.
Any idea why? I'm new at this and learning through YouTube. The instructor seems legit and easy to follow.
5
u/Mrminecrafthimself Apr 13 '26
Can I ask why not just say…
WHERE PlanID IN (‘ID1’, ‘ID2’, ‘ID3’)
1
u/Massive_Show2963 Apr 13 '26
What was the actual error you were getting?
It is possible if you copied and pasted the WHERE clause from some other editor, the single quote characters may not have been be recognized by SQL. That could be why re-entering them probably worked.
1
u/trebor_indy Apr 13 '26
I've seen folks copy from Microsoft Word and similar word processing systems, where apostrophes and double-quotes come in two forms, like below (look closely):
Those are NOT the same as the single-quote character: '