Hi.....

There is a problem with the following mysql query

create table emp2 (Leave decimal(12,2) default NULL)

Error message
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 'Leave decimal(12,2) default NULL)' at line 1


If I type the query as..
create table emp2(Leav decimal(12,2) default NULL)

Then it will executed successfully..What is the problem with the field 'Leave'?Is it a key word?

Recommended Answers

All 3 Replies

Yes, it is a keyword:
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

However, if you really want to use that, enclose with backticks:
create table emp2 (`Leave` decimal(12,2) default NULL)

and when you do any operation on that field (SELECT/UPDATE/INSERT,etc) don't forget to ALSO put the backticks around it as well.

It is very help full.Thank you very much..

Glad to help.

PS: Don't forget to mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.