This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 8 years ago.
I've came across strange issue. I know I'm missing something very minor. Can Any One solve the problem plz.
This is my table:
cat_id name desc
1 Cricket Schedule
2 Live Cricket Live Cricket Desc
3 Fixtures
4 Videos
I ran following update query and worked fine.
UPDATE cats
set name='New Fixtures'
WHERE cat_id='3'
But When I Run Following Query, It returns error:
#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 'desc='New Fixtures Desc' WHERE cat_id='3'' at line 1
The Query is :
UPDATE cats
set desc='New Fixtures Desc'
WHERE cat_id='3'
Plz Tell me What I am Missing Here
desc is a reserved keyword, you must escape it with backtick
UPDATE cats
set `desc` = 'New Fixtures Desc'
WHERE cat_id = '3'
MySQL Reserved Keywords List
Related
This question already has answers here:
How do you use the "WITH" clause in MySQL?
(7 answers)
Closed 6 years ago.
I want to use a SQL Query with the WITH clause an I get a Syntax Error.
I´m using MySQL Version 5.6.28
Here a simple Code example
WITH alias_test AS (SELECT id, title FROM `tips_locations`)
SELECT id, title
FROM alias_test
Here the error I get in my SQL Tool
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 'alias_test AS (SELECT id, title FROM tips_locations) SELECT
id, title FROM ali' at line 1
Can you Help me?
MySQL doesn't support WITH clause or CTE and thus the error. Alternative, you can either use a temporary table or a normal table like
CREATE TEMPORARY TABLE alias_test AS
SELECT id, title FROM `tips_locations`;
SELECT id, title
FROM alias_test;
This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 6 years ago.
I'm trying to run the query
select * from Order;
I m getting the following syntax error in sql fiddle.
Could not figure out the correct syntax.
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 'Order' at line 1
http://sqlfiddle.com/#!9/aee9e/62
Order is a MySQL reserved word. Change your query to use backticks:
select * from `Order`;
Order is a reserved keyword for mysql refer to this link;
Simply change your table name from Order to orders.
Bye!
This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed last month.
I have a table. Name of the table is "group"
I run query like this:
SELECT * FROM GROUP
There exist error like this:
Error Code: 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 'group
LIMIT 0, 1000' at line 1
Any solution to solve my problem?
use backquote :
SELECT * FROM `GROUP`
you can also alias your table name for later use in WHERE clause for instance:
SELECT * FROM `GROUP` g WHERE g.id = 1
I'm used to running on an Oracle database, so I'm not really quite sure how to trouble shoot this problem. I've narrowed down a simple example of my query to the following:
SELECT 0 as gm_rowID,
'-ALL Grantmakers-' as grantmakerName
FROM dual
GROUP BY 2
phpMyAdmin runs the SQL with the following error:
#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 'ORDER BY 2 LIMIT 0, 30' at line 1
Oracle can run this query just fine. MySQL can run the query without the GROUP BY clause. Any ideas?
--Here is the entire query:
SELECT
p.grantmaker_rowid as gm_rowID,
gm.grantmaker_companyName as grantmakerName
FROM grantmaker_info gm, proposal_submission p
WHERE 0=0
AND p.grantmaker_rowid = gm.grantmaker_rowid
UNION
SELECT
0 as gm_rowID,
'-ALL Grantmakers-' as grantmakerName
FROM dual
ORDER BY 2
GROUP BY 2
LIMIT 0 , 30
Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column
names, column aliases, or column positions. Column positions are
integers and begin with 1
From: http://dev.mysql.com/doc/refman/5.0/en/select.html
Unless you only have 1 column in that table, it should run fine. My suggestion however would be to reference the column name (or alias) of whatever you're trying to GROUP BY.
edit: My only other suggestion is to include the SHOW CREATE TABLE output for that table.
edit2: Ok I see you've updated your question. Why not instead of ORDER BY 2, you ORDER BY grantmakerName (if that's the column you want to order by?)
This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 8 years ago.
I'm trying to do a really simple sort on a varchar column, and I get a syntax error. Tested both with PHP and phpmyadmin.
This is the query:
SELECT * FROM cards_available_properties ORDER BY option
this is the error:
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 'option LIMIT 0, 30' at line 1
OPTION is a reserved keyword. escape it with backtick.
SELECT * FROM cards_available_properties ORDER BY `option`
MySQL Reserved Words