Problems with SQL Query

Problems with SQL Query

am 08.03.2007 19:10:03 von alex.waldner

Hey there,

I'm trying to run a SQL Query but really can't find what's wrong with
it - I keep getting a 1064 error.

INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
'2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
'0', '0.4', '0', '0', '0', '0', '0', '')

Can anyone spot an error?

Re: Problems with SQL Query

am 08.03.2007 19:19:57 von Shion

alex.waldner@gmail.com wrote:
> Hey there,
>
> I'm trying to run a SQL Query but really can't find what's wrong with
> it - I keep getting a 1064 error.
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', '')
>
> Can anyone spot an error?
>

And the whole error message was?

--

//Aho

Re: Problems with SQL Query

am 08.03.2007 22:13:36 von Paul Lautman

alex.waldner@gmail.com wrote:
> Hey there,
>
> I'm trying to run a SQL Query but really can't find what's wrong with
> it - I keep getting a 1064 error.
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', '')
>
> Can anyone spot an error?

Try giving us the complete error message!

Re: Problems with SQL Query

am 09.03.2007 07:29:27 von alex.waldner

Sorry - here you've got the whole error message.

An Error Was Encountered
Error Number: 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
comment) VALUES (NULL, ' at line 1

INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
'2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
'0', '0.4', '0', '0', '0', '0', '0', NULL)

Re: Problems with SQL Query

am 09.03.2007 08:36:54 von Shion

alex.waldner@gmail.com wrote:
> Sorry - here you've got the whole error message.
>
> An Error Was Encountered
> Error Number: 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
> comment) VALUES (NULL, ' at line 1
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', NULL)
>

Dual is a reserved word and should really not be used for
database/table/column/function/procedure names, I strongly recommend you
rename it, you can also use the "single quotes" ``.

Notice the difference from the usual single quote ' and the one used for
database/table/column names which is tittle a bit `.

--

//Aho

Re: Problems with SQL Query

am 09.03.2007 15:04:15 von Captain Paralytic

On 9 Mar, 06:29, alex.wald...@gmail.com wrote:
> Sorry - here you've got the whole error message.
>
> An Error Was Encountered
> Error Number: 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
> comment) VALUES (NULL, ' at line 1
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', NULL)

Following on from Aho, I always "tick" all my table/alias/column names
as a matter of course. Saves lots of headaches e.g. having a column
called `group`.

Re: Problems with SQL Query

am 09.03.2007 21:17:20 von Iceman

alex.waldner@gmail.com napisa³(a):
> Sorry - here you've got the whole error message.
>
> An Error Was Encountered
> Error Number: 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
> comment) VALUES (NULL, ' at line 1
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', NULL)
>

could you show me how do you create this table? maybe id field cann't be
NULL

Re: Problems with SQL Query

am 10.03.2007 00:20:29 von alex.waldner

On Mar 9, 8:36 am, "J.O. Aho" wrote:
> alex.wald...@gmail.com wrote:
> > Sorry - here you've got the whole error message.
>
> > An Error Was Encountered
> > Error Number: 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
> > comment) VALUES (NULL, ' at line 1
>
> > INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> > blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> > CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> > '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> > '0', '0.4', '0', '0', '0', '0', '0', NULL)
>
> Dual is a reserved word and should really not be used for
> database/table/column/function/procedure names, I strongly recommend you
> rename it, you can also use the "single quotes" ``.
>
> Notice the difference from the usual single quote ' and the one used for
> database/table/column names which is tittle a bit `.
>
> --
>
> //Aho

Problem solved :D

The issue was the 'Dual'. I renamed it and now it works just fine.
Thanks a lot for your help all of you!

Re: Problems with SQL Query

am 10.03.2007 11:18:37 von Shion

Alex wrote:

>> Dual is a reserved word and should really not be used for
>> database/table/column/function/procedure names, I strongly recommend you
>> rename it, you can also use the "single quotes" ``.
>> Notice the difference from the usual single quote ' and the one used for
>> database/table/column names which is tittle a bit `.
> Problem solved :D
> The issue was the 'Dual'. I renamed it and now it works just fine.
> Thanks a lot for your help all of you!
>
Here is a list of reserved words in MySQL, it will apply quite well into other
sql databases too: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

--

//Aho