Re: single quotes in a select statement

Will Trillich <will@serensoft.com>

From: will trillich <will@serensoft.com>
To: Pgsql-General <pgsql-general@postgresql.org>
Date: 2001-05-11T21:26:39Z
Lists: pgsql-general
On Fri, May 11, 2001 at 11:27:16AM -0400, Joseph wrote:
> Is it possible to have one field
> like the following
> 
> 'some text' || case when t='1' then '1' else '2' end
> 
> I don't know how to differentiate the different quotes.

double quotes are to "glue together" attributes that would
otherwise seem to be separate tokens:

	create table "my table here" (
		"some field" varchar(20),
		"yet another" serial,
		"the last one" float8
	);

single quotes delineate string values:

	select 'here: '
			|| "some field"
			|| ' plus also '
			|| string("yet another"/"the last one")
		from "my table here";

also note that uppercase/lowercase are significant on "quoted"
attributes, but on unquoted ones everything winds up as lowercase:

	> create table mytable ("myField" varchar(10));
	CREATE
	> insert into MYTABLE(myField)values('one');
	ERROR:  Relation 'mytable' does not have attribute 'myfield'
	> insert into MYTABLE("myField")values('one');
	INSERT 1063721 1

> Can I use double quotes or some other kind of quotes inside my case
> statement?

parentheses often work wonders. but the only quotes for strings
(that i'm aware of) are 'single quotes'.

to include a single quote inside a string, try

	'it''s maybe like this'
	'we\'re not always right'

-- 
don't visit this page. it's bad for you. take my expert word for it.
http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!