Thread: When To Use Quotes

When To Use Quotes

From
Carlos Mennens
Date:
I'm trying to understand when in SELECT statements should and should I
not use single quotes to filter my results. For example:

SELECT * FROM people
WHERE fname = 'James';

or

SELECT * FROM price
WHERE msrb
BETWEEN 50 AND 100;

Now is it correct to say that in PostgreSQL or ANSI SQL in general I
should use 'single quotes' when the condition is strictly a numerical
data type value and everything else should be inside 'single quotes'?


Re: When To Use Quotes

From
"Plugge, Joe R."
Date:
Should match to the data type of the filtered value, so CHAR,VARCHAR,All DATE TYPES should be quoted.  INTEGER, BIGINT,
SMALLINTshould not .... 

-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Carlos Mennens
Sent: Thursday, January 05, 2012 7:56 AM
To: PostgreSQL (SQL)
Subject: [SQL] When To Use Quotes

I'm trying to understand when in SELECT statements should and should I not use single quotes to filter my results. For
example:

SELECT * FROM people
WHERE fname = 'James';

or

SELECT * FROM price
WHERE msrb
BETWEEN 50 AND 100;

Now is it correct to say that in PostgreSQL or ANSI SQL in general I should use 'single quotes' when the condition is
strictlya numerical data type value and everything else should be inside 'single quotes'? 

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql