+ 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?
7 Answers
+ 6
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)
+ 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.
+ 3
Single quotes are mostly used in SQL double quotes aren't used that much
+ 2
Gonna have to research on that I guess. I personally hadn't used or needed to use it.
+ 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 đ
+ 1
Ipang Thanks Ipang
Is there any specific use of double quotes in SQL?
+ 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)