![]() |
| sql syntax to insert values with reserved words |
|
dbsturtevant
|
Hi, I suspect there is a very easy answer for this, but I'm not sure what it is...
I recently switched to a new hosting service and suddenly the sql routines that used to run fine are having trouble. Specifically, I'm getting a syntax error 1064. I suspect this is related to reserved words ('and' and 'on') in the values for the data that I am trying to insert. I tried using ' ' ' and ' " ' around the values but that didn't work. Any other ideas? Thanks, Dave |
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
If you can provide me a more specific example of a query/command gone awry, I can help you fix it
But taking a preliminary stab at this one... you can try delimiting those words with double quotes, but usually that only applies when they're being used as identifiers. Those words appearing in the data should not cause any problems and is why I asked to see a more specific and complete query/command as I suspect it's something else causing the issue. |
||||||||||||
|
|
|||||||||||||
|
dbsturtevant
|
I appreciate your help.
Here's a sample query: INSERT INTO table (title, table.year, table.medium, table.keyword) VALUES (‘Jackson, MA’, ‘2008’, ‘acrylic and oil on board’, ‘Jackson, MA, colonial, northeast’); Where the single quotes are now, I tried using full quotes, but that didn't seem to help. In both cases I get the following error message: SQL query: INSERT INTO table( title, table.year, table.medium, table.keyword ) VALUES ( ‘Jackson, MA’, ‘2008’, ‘acrylic AND oil ON board’, ‘Jackson, MA, colonial, northeast’ ) MySQL said: #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 'on board’, ‘Jackson, MA, colonial, northeast’)' at line 2 |
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
The only thing I've done is change your single quotes to these: '
by hitting the double quote " key next to the enter button. After doing that it all seemed to work fine for me. Those funky single quotes seem to be the issue as I recreated the error exactly, and then I fixed it. Just change the quotes to standard single quotes |
||||||||||||
|
|
|||||||||||||
|
dbsturtevant
|
Ahhh! I knew it had to be something simple!
Thank you for your help!!! |
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
Anytime
|
||||||||||||
|
|
|||||||||||||
| sql syntax to insert values with reserved words |
|
||
|


