+ 1
SQL DATA
While I was taking the lessons, I got a doubt Here it is: " Why are only single quotes are used why not double quotes like Python? "
7 Antworten
+ 4
It all depends on context.
* Single quotes are commonly used to denote string and date/datetime literals
'This is a string' -- a string
'2024-07-06' -- date
'2024-07-06 14:35:41' -- datetime
* Double quotes are not as common, but it is said they are used to refer table or column names. From what I read; only PostgreSQL implements the use case, not all DBMS supports it for similar functionality.
It is more common to see backticks used to wrap table/column names in MySQL and MariaDB. I no longer recall whether double quotes were used in MSSQL, latest updates may differ.
* Backticks are commonly used to refer table/column name, or where use of a reserved word as table/column name was considered (it is rather discouraged)
SELECT `id`, `user_name`, `password` FROM `users`;
cmiiw :)
+ 3
The short reason is that Python and SQL are different languages, and there are differences in their syntax, including how they represent strings. SQL allows single quotes only.
0
Hi
0
Tibor Santa, finally, a correct answer. Dikshit Verma, by the way, in python single quotes are only usually used for quoting quotes Ex: print(‘“what?” He said’).
Hope that answered your question
Cheers
0
Can anyone here be my boss
I need to learn this