pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sill-II, Stephen <Stephen.Sill-II@ost.dot.gov>
To: 'Ross J. Reedstrom ' <reedstrm@rice.edu>
Cc: ''pgsql-sql@postgresql.org' ' <pgsql-sql@postgresql.org>
Subject: Re: referencing column names properly
Date: Sun, 9 Feb 2003 09:18:05 -0500
Message-ID: <4BAE87828F06EB45B2641B83D370350F45E5@ostex002.ad.ost.dot.gov> (raw)

 Thanks much!  After much experimentation, I figured it out.  I remember
reading in the postgres oreily book that if you don't quote the identifiers,
that it converts them all to lowercase for processing.  Does the dash in the
name also require the name to be quoted?

Thanks again!
Stephen Sill II

-----Original Message-----
From: Ross J. Reedstrom
To: Sill-II, Stephen
Cc: 'pgsql-sql@postgresql.org'
Sent: 2/9/2003 12:50 AM
Subject: Re: [SQL] referencing column names properly

On Sat, Feb 08, 2003 at 06:34:31PM -0500, Sill-II, Stephen wrote:
> I have a table called logs with several columns whose names have '-'
in
> them, e.g.   User-Name
> 
> I'm having trouble referencing these columns with SELECT statements.
> 
> What would the proper way to address these in a statement like this?
> 
> SELECT User-Name, max(Date), max(Time) from logs;

 SELECT "User-Name", max("Date"), max("Time") from logs;

Assuming the MulTiCasIng you show is also in the table. SQL lets you
put anything at all in an identifier (table or column name) as long
as you quote it with double-quotes (")

Ross



view thread (5+ messages)  latest in thread

Message-ID: <4BAE87828F06EB45B2641B83D370350F45E5@ostex002.ad.ost.dot.gov>
Permalink:  ../4BAE87828F06EB45B2641B83D370350F45E5@ostex002.ad.ost.dot.gov/
Also on:    postgresql.org/message-id/4BAE87828F06EB45B2641B83D370350F45E5@ostex002.ad.ost.dot.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Stephen.Sill-II@ost.dot.gov, reedstrm@rice.edu
  Subject: Re: referencing column names properly
  In-Reply-To: <4BAE87828F06EB45B2641B83D370350F45E5@ostex002.ad.ost.dot.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox