LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-06-2005, 09:27 AM   #1
sekelsenmat
Member
 
Registered: Apr 2005
Location: São Paulo - Brazil
Distribution: Mageia Linux 1
Posts: 353

Rep: Reputation: 30
help with simple sql statement


Hi,

I set up a mysql on my PC, created a table and now I want to add data to it, but mysql keeps complaining that my statement is wrong, but it doesn't provice any information about what is wrong.

Here is my table's description on the command line:

Code:
mysql> describe Acessos;
+----------------+-------------+------+-----+-------------------+-------+
| Field          | Type        | Null | Key | Default           | Extra |
+----------------+-------------+------+-----+-------------------+-------+
| ip             | varchar(50) | YES  |     | NULL              |       |
| pais           | varchar(5)  | YES  |     | NULL              |       |
| horario        | timestamp   | YES  |     | CURRENT_TIMESTAMP |       |
| navegador      | varchar(20) | YES  |     | NULL              |       |
| plataforma     | varchar(20) | YES  |     | NULL              |       |
| resolucao      | varchar(10) | YES  |     | NULL              |       |
| cores          | int(11)     | YES  |     | NULL              |       |
| listadeplugins | varchar(20) | YES  |     | NULL              |       |
+----------------+-------------+------+-----+-------------------+-------+
8 rows in set (0,00 sec)
And now my SQL statement:

mysql> INSERT INTO Acessos ('100.100.0.0','br','','Firefox','Linux','800x500', 256 , '' );

This will give me the error: ERROR 1064 (42000): 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 ''100.100.0.0','br','','Firefox','Linux','800x500', 256 , '' )' at line 1

Does anyone know what I am doing wrong? I think this could be on the TIMESTAMP value, but I tryed many values and it won't work...

Better yet, does anyone know a (free) SQL statement checker that will acctually give me a hint about what I am doing wrong?

thanks,

Felipe
 
Old 08-06-2005, 09:34 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
If you're not putting anything into the horario and listadeplugins columns yourself, maybe you should use

INSERT INTO Acessos(ip, pais, navegador, plataforma, resolucao, cores) VALUES('100.100.0.0','br','Firefox','Linux','800x500', 256);

Last edited by Nylex; 08-06-2005 at 09:35 AM.
 
Old 08-06-2005, 09:50 AM   #3
sekelsenmat
Member
 
Registered: Apr 2005
Location: São Paulo - Brazil
Distribution: Mageia Linux 1
Posts: 353

Original Poster
Rep: Reputation: 30
Thanks!

The "VALUES" was missing...

I'm just learning SQL, and it would be much better if it gave me reasonable error messages instead of "check you sql statement" =/

thanks again,
 
Old 08-06-2005, 09:57 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Agreed, that message is a pain in the rear end . Have you seen the SQL guide at www.w3schools.com? If not, it's pretty good.
 
Old 08-06-2005, 10:54 AM   #5
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
If you're into MySQL, you might find these links a great help:

http://dev.mysql.com/doc/mysql/en/index.html
http://dev.mysql.com/doc/mysql/en/da...ipulation.html
http://dev.mysql.com/doc/mysql/en/data-definition.html
 
Old 08-06-2005, 11:39 AM   #6
sekelsenmat
Member
 
Registered: Apr 2005
Location: São Paulo - Brazil
Distribution: Mageia Linux 1
Posts: 353

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by Harishankar
If you're into MySQL, you might find these links a great help:

http://dev.mysql.com/doc/mysql/en/index.html
http://dev.mysql.com/doc/mysql/en/da...ipulation.html
http://dev.mysql.com/doc/mysql/en/data-definition.html
Thanks, I'm setting my first Apache+PHP+MySQL server. The SQL code will acctually belong inside a php file.
 
Old 08-06-2005, 12:01 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Unfortunately, the SQL grammar that is used by MySQL still has no decent error-messages. It simply spits out a fragment of text beginning approximately where the parse failed, and tells you to find the problem. Curiously, quite a few SQL engines are like that.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL statement to get the last row in a table oulevon Programming 11 04-03-2009 08:30 PM
Migrating from MS-SQL server to My-SQL emailssent Linux - Networking 2 02-07-2005 02:20 PM
Which SQL is suitable for EMbedded SQL on C? hk_michael Programming 4 01-10-2005 05:07 PM
mysql sql statement help mrtwice Programming 4 12-02-2003 10:04 AM
SQL statement glj Programming 1 10-12-2001 09:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration