Re: trouble with query

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Jay <jspothar(at)cs(dot)uccs(dot)edu>
Cc: General Postgres <pgsql-general(at)postgresql(dot)org>
Subject: Re: trouble with query
Date: 2004-08-04 14:47:57
Message-ID: 1091630876.31602.2869.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2004-08-04 at 03:28, Jay wrote:
> hi people,
> i am using mysql and i am having the following problem....
> I know this is not the correct to ask this problem.

Surely a MySQL mailing list could have answered this? I thought they
had good community support.

> but i am need of
> help urgently thats why i posted this here.
> but please help
>
>
> i have a table with the following fields .when i try to enter data i get
> the following error.any help would b
...
>
> when i enter the following data
>
> INSERT INTO form VALUES
> ('yes',,'yes',,'yes',,'yes','yes','yes','yes','yes','yes','yes','no','yes','no','yes','yes','yes','yes','john',,'',,,'','',,'','',,'','',,'');
>
> i get the following error
> ERROR 1064: You have an error in your SQL syntax.

Even MySQL doesn't accept that kind of thing!

You have doubled commas at several places in the VALUES list. I suppose
those are meant to be nulls - you should specify NULL instead of nothing
at all:

INSERT INTO form VALUES
('yes',NULL,'yes',NULL,'yes',NULL,'yes',...);

The way you have written it is bad practice any way. You should use
specific column names rather than relying on the current order in the
table:

INSERT INTO form (human_subj, animal_subj, toxic,...)
VALUES ('yes','yes','yes',...);

This will continue to work even if the table's column order changes for
some reason.
--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"And not only so, but we glory in tribulations also;
knowing that tribulation worketh patience; And
patience, experience; and experience, hope."
Romans 5:3,4

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dave Cramer 2004-08-04 14:55:36 Re: trash talk
Previous Message terry 2004-08-04 14:21:47 Re: Creating an hourly backup