Re: trouble with query

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: trouble with query
Дата
Msg-id 1091630876.31602.2869.camel@linda
обсуждение исходный текст
Ответ на trouble with query  (Jay <jspothar@cs.uccs.edu>)
Список 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@lfix.co.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


В списке pgsql-general по дате отправления:

Предыдущее
От:
Дата:
Сообщение: Re: Creating an hourly backup
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: trash talk