[DB-SIG] How to escape special field name, mysql?

Carsten Haese carsten at uniqsys.com
Wed Aug 8 03:37:10 CEST 2007


On Wed, 2007-08-08 at 00:40 +0200, Paul Boddie wrote:
> On Tuesday 07 August 2007 19:17, Carsten Haese wrote:
> > On Tue, 2007-08-07 at 11:58 -0500, Lukasz Szybalski wrote:
> > >
> > > When i do:
> > > insert into tablename(id,desc)VALUES(1,'some text')
> > >
> > > How do I escape 'desc'?
> >
> > insert into tablename(id,`desc`) ...
> 
> Obviously MySQL supports the above, but I believe that the standard way is to 
> use double quotes:
> 
> insert into tablename (id, "desc") values (1, 'some text')

That is the PostgreSQL way. The standard way (at least as far as
Informix understands it) is not to quote table/column names at all and
let the parser worry about determining whether the word it's looking at
is the name of a thing or a keyword. And worry it will, if you are
insane enough to write queries like "select select as as from from where
where = 1", which is valid SQL given the right schema, and it's the
reason why writing a standards compliant SQL parser is a pain in the
neck.

-- 
Carsten Haese
http://informixdb.sourceforge.net




More information about the DB-SIG mailing list