Ankur
Ankur

Reputation: 51100

What is wrong with this SQL statement

The error is:

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 'RA---SIN', 'DEC--SIN', 0.0,-90.0)' at line 1

INSERT INTO files_table (filename, folder, survey, telescope, author, observer, equinox, ctype1, ctype2, crval1, crval2) VALUES('H001_abcde_luther_chop.fits', 'C:\dev\data\FITS\surveys\', '', '','', -1.0, 'RA---SIN', 'DEC--SIN', 0.0,-90.0)

The statement that created the table was (the line breaks are just for ease of reading)

 create table files_table (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 filename varchar(255), folder varchar(255), survey varchar(255), telescope varchar(255), 
 author varchar(255), observer varchar(255), equinox double, ctype1 varchar(255), ctype2
 varchar(255), crval1 double, crval2 double);

Upvotes: 3

Views: 191

Answers (3)

philiphobgen
philiphobgen

Reputation: 2284

I think it's because you are missing a value

You have 11 columns named and only 10 values

Upvotes: 6

Zlatko
Zlatko

Reputation: 19569

This is because you're trying to insert RA--SIN into equinox column, which is of type double.

I believe you're missing an '', so the query would work like this:

INSERT INTO files_table (filename, folder, survey, telescope, author, observer, equinox, ctype1, ctype2, crval1, crval2) VALUES('H001_abcde_luther_chop.fits', 'C:\dev\data\FITS\surveys\', '', '','','' -1.0, 'RA---SIN', 'DEC--SIN', 0.0,-90.0)

Upvotes: 0

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120917

It is because of the backslash before the single quote. Escape your backslashes (like so \\) and it should be ok.

Upvotes: 12

Related Questions