Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between single quotes and double quotes in PostgreSQL?

Tags:

sql

postgresql

I am new to PostgresSQL.I tried

select * from employee where employee_name="elina"; 

But that results error as follows:

ERROR: column "elina" does not exist. 

Then I tried by replacing double quotes with single quotes as follows:

select * from employee where employee_name='elina'; 

It result fine..So what is the difference between single quotes and double quotes in postgresql.If we can't use double quotes in postgres query,then if any other use for this double quotes in postgreSQL?

like image 557
jisna Avatar asked Dec 30 '16 12:12

jisna


People also ask

What is the difference between single and double quotes in SQL?

Single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, but that can vary from database to database. Stick to using single quotes.

What is the difference between single quotes and double quotes?

The main difference between double quotes and single quotes is, double quotes are used to denote a speech or a quotation whereas single quotes are used to indicate quote within a quotation.

Why use single quotes instead of double quotes?

The most common reason to use single quotation marks is to quote someone who is quoting someone else. The rules are different in British English, but in American English, you enclose the primary speaker's comments in double quotation marks, and then you enclose the thing they are quoting in single quotation marks.

How do I escape double quotes in PostgreSQL?

Quotes and double quotes should be escaped using \.


1 Answers

Double quotes are for names of tables or fields. Sometimes You can omit them. The single quotes are for string constants. This is the SQL standard. In the verbose form, your query looks like this:

select * from "employee" where "employee_name"='elina'; 
like image 67
Michas Avatar answered Oct 11 '22 10:10

Michas