Re: trouble with query

Lists: pgsql-general
From: Jay <jspothar(at)cs(dot)uccs(dot)edu>
To: General Postgres <pgsql-general(at)postgresql(dot)org>
Subject: trouble with query
Date: 2004-08-04 02:28:45
Message-ID: 411049DD.9090807@cs.uccs.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

hi people,
i am using mysql and i am having the following problem....
I know this is not the correct to ask this problem. 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

> +---------------------------+---------------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default |
> Extra |
> +---------------------------+---------------+------+-----+---------+-------+
> | human_subj | char(3) | YES | | NULL
> | |
> | human_subj_approval_date | timestamp(6) | YES | | NULL
> | |
> | animal_subj | char(3) | YES | | NULL
> | |
> | animal_subj_approval_date | timestamp(6) | YES | | NULL
> | |
> | toxic | char(3) | YES | | NULL
> | |
> | toxic_approval_date | timestamp(6) | YES | | NULL
> | |
> | curriculum_change | char(3) | YES | | NULL
> | |
> | compensate_employee | char(3) | YES | | NULL
> | |
> | course_release | char(3) | YES | | NULL
> | |
> | subcontract | char(3) | YES | | NULL
> | |
> | sponsor_org | char(3) | YES | | NULL
> | |
> | additional_space | char(3) | YES | | NULL
> | |
> | search_waiver | char(3) | YES | | NULL
> | |
> | generate_income | char(3) | YES | | NULL
> | |
> | classified | char(3) | YES | | NULL
> | |
> | suspended | char(3) | YES | | NULL
> | |
> | institute_affected | char(3) | YES | | NULL
> | |
> | tution_included | char(3) | YES | | NULL
> | |
> | tenure | char(3) | YES | | NULL
> | |
> | pi_assurance | char(3) | YES | | NULL
> | |
> | pi_sign | char(40) | YES | | NULL
> | |
> | pi_date | timestamp(6) | YES | | NULL
> | |
> | co_pi_assurance_1 | char(3) | YES | | NULL
> | |
> | co_pi_sign | char(40) | YES | | NULL
> | |
> | co_pi_1_date | timestamp(14) | YES | | NULL
> | |
> | co_pi_assurance_2 | char(3) | YES | | NULL
> | |
> | co_pi_sign2 | char(40) | YES | | NULL
> | |
> | co_pi_2_date | timestamp(14) | YES | | NULL
> | |
> | co_pi_assurance_3 | char(3) | YES | | NULL
> | |
> | co_pi_sign3 | char(40) | YES | | NULL
> | |
> | co_pi_3_date | timestamp(14) | YES | | NULL
> | |
> | co_pi_assurance_4 | char(3) | YES | | NULL
> | |
> | co_pi_sign4 | char(40) | YES | | NULL
> | |
> | co_pi_4_date | timestamp(14) | YES | | NULL
> | |
> | proj_id | int(5) | YES | | NULL
> | |
> +---------------------------+---------------+------+-----+---------+-------+
> 35 rows in set (0.00 sec)

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. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near ''yes',,'yes',,'yes','yes','yes','yes','yes','yes','yes','no','y

please help!
thanks
jay


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
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