+ 2

Are double quotes same as single quotes in SQL (like python)?

Hey everyone, yesterday I completed the SQL course on Sololearn. When doing the last Code Project named "zoo", I got error when I used double quotes for inserting string values but when I replaced the double quotes with single quotes, I successfully solved the challenge. <------ part of the code where I got error ------> INSERT INTO Animals (name, type, country_id) VALUES ("Slim", "Giraffe", 1); ××× ERROR I GOT ×××× ERROR: Column slim does not exist when double quoted strings replaced with single quotes, I passed the test <------ code that cleared the test ------> INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); Why that error when using double quotes?

22nd Nov 2021, 5:47 AM
Sandeep
Sandeep - avatar
7 Answers
+ 4
Concluded from below links, Single quotes are for string, date or datime values, backticks are for table/column names and aliases. https://chartio.com/learn/sql-tips/single-double-quote-and-backticks-in-mysql-queries/ https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql (Edited for correctness)
22nd Nov 2021, 6:52 AM
Ipang
+ 3
String and date or date/time expressions use single quotes IIRC. I remember reading somewhere (forgot where), that use of double quotes in queries was possible, but as I recall, a modification of default setting was required to do, and am not clearly remembering whether that was a vendor specific feature.
22nd Nov 2021, 6:05 AM
Ipang
+ 3
Single quotes are mostly used in SQL double quotes aren't used that much
23rd Nov 2021, 5:10 PM
M.A.R.S ☕🥧🌯🎩
M.A.R.S ☕🥧🌯🎩 - avatar
+ 2
Gonna have to research on that I guess. I personally hadn't used or needed to use it.
22nd Nov 2021, 6:16 AM
Ipang
+ 2
Oops, I just saw that (about double quotes) from the stackoverflow first comment (below the question). It said ... double quotes are for delimited identifiers, e.g. "tablename" I guess I misunderstood that one 😁
22nd Nov 2021, 8:43 AM
Ipang
+ 1
Ipang Thanks Ipang Is there any specific use of double quotes in SQL?
22nd Nov 2021, 6:15 AM
Sandeep
Sandeep - avatar
+ 1
Ipang Thanks a lot 👍 This link is really useful. I think you made a typo in your reply. Back Quotes (`) are for table name or table alias.(not double quotes)
22nd Nov 2021, 8:20 AM
Sandeep
Sandeep - avatar