MySQL #1064 - You have an error in your SQL syntax [closed] - mysql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying to create table then show the following error. But I can't found the error. I am new in Mysql Please help me..
SQL query:
--
-- Dumping data for table `files`
--
-- --------------------------------------------------------
--
-- Table structure for table `post`
--
CREATE TABLE IF NOT EXISTS `offer` (
offer_id INT( 9 ) NOT NULL AUTO_INCREMENT ,
offer_category VARCHAR( 50 ) CHARACTER SET utf8 NOT NULL ,
offer_type VARCHAR( 50 ) CHARACTER SET utf8 NOT NULL ,
sub_category_id INT( 9 ) NOT NULL ,
category_id INT( 9 ) NOT NULL ,
state_id INT( 9 ) NOT NULL ,
city_id INT( 9 ) NOT NULL ,
location_id INT( 9 ) NOT NULL ,
file_id INT( 9 ) NOT NULL ,
title VARCHAR( 50 ) CHARACTER,
description TEXT CHARACTER,
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
exp_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
shop_id INT( 9 ) NOT NULL ,
status TINYINT( 1 ) NOT NULL ,
PRIMARY KEY ( offer_id )
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =63;
the error is,
MySQL said: Documentation
#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 '
`description` text CHARACTER,
`date` timestamp NOT NULL DEFAULT CURRENT_TI' at line 22

Issues :
title VARCHAR( 50 ) CHARACTER : VARCHAR(50) is enough , MySQL doesn't support this syntax.
description TEXT CHARACTER : use one TEXT or CHAR
Two columns can't have CURRENT_TIMESTAMP
Try this one
CREATE TABLE IF NOT EXISTS `offer` (
`offer_id` INT( 9 ) NOT NULL AUTO_INCREMENT ,
`offer_category` VARCHAR( 50 ) CHARACTER SET utf8 NOT NULL ,
`offer_type` VARCHAR( 50 ) CHARACTER SET utf8 NOT NULL ,
`sub_category_id` INT( 9 ) NOT NULL ,
`category_id` INT( 9 ) NOT NULL ,
`state_id` INT( 9 ) NOT NULL ,
`city_id` INT( 9 ) NOT NULL ,
`location_id` INT( 9 ) NOT NULL ,
`file_id` INT( 9 ) NOT NULL ,
`title` VARCHAR( 50 ) ,
`description` TEXT ,
`date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`exp_date` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ,
`shop_id` INT( 9 ) NOT NULL ,
`status` TINYINT( 1 ) NOT NULL ,
PRIMARY KEY ( `offer_id` )
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =63;

Related

Database not importing

Error
##
--
-- Database: verticalned
-- --------------------------------------------------------
-- Table structure for table announcements
CREATE TABLE `announcements` (
`id` INT( 10 ) NOT NULL ,
`description` VARCHAR( 6000 ) DEFAULT NULL ,
`links` VARCHAR( 100 ) DEFAULT NULL ,
`first` TINYINT( 1 ) DEFAULT > NULL ,
`second` TINYINT( 1 ) DEFAULT NULL ,
`third` TINYINT( 1 ) DEFAULT NULL ,
`fourth` TINYINT( 1 ) DEFAULT NULL ,
`staff` VARCHAR( 22 ) DEFAULT NULL ,
`time` DATETIME( 2 ) DEFAULT NULL ,
`subject` VARCHAR( 100 ) DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
MySQL said: Documentation
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 '(2) DEFAULT NULL, subject varchar(100) DEFAULT NULL )
ENGINE=InnoDB DEFAULT ' at line 20
version
Looks like the mysql version you are using (probably older than 5.6.4) does not accept precision (fractional seconds). You can bypass the issue by replacing ..., time DATETIME(2) DEFAULT NULL ,... with ... , time DATETIME DEFAULT NULL ,....
However, you should solve the issue by either changing the data type to timestamp or upgrading MySQL server to a version later than 5.6.4
CREATE TABLE `announcements` (
`id` INT(10) NOT NULL,
`description` VARCHAR(6000) DEFAULT NULL,
`links` VARCHAR(100) DEFAULT NULL,
`first` TINYINT( 1 ) DEFAULT NULL ,
`second` TINYINT( 1 ) DEFAULT NULL ,
`third` TINYINT( 1 ) DEFAULT NULL ,
`fourth` TINYINT( 1 ) DEFAULT NULL ,
`staff` VARCHAR( 22 ) DEFAULT NULL ,
`time` DATETIME( 2 ) DEFAULT NULL ,
`subject` VARCHAR( 100 ) DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
obvoiusly theres nothing wrongn with your code. just add the slanted quotes
CREATE TABLE announcements (
id INT NOT NULL ,
description VARCHAR( 6000 ) DEFAULT NULL ,
links VARCHAR( 100 ) DEFAULT NULL ,
firstTINYINT DEFAULT NULL ,
secondTINYINT DEFAULT NULL,
thirdTINYINT DEFAULT NULL ,
fourthTINYINT DEFAULT NULL,
staffVARCHAR(22) DEFAULT NULL ,
timeDATETIME DEFAULT NULL ,
subject` VARCHAR( 100 ) DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
Please remove character number from INT and TINYINT, and add the slanted quotes your code should work.

mysql syntax error why?

mysql query
CREATE TABLE IF NOT EXISTS 'sadakin'.'gcm_users' (
'id' int( 11 ) NOT NULL AUTO_INCREMENT ,
'gcm_regid' text,
'name' varchar( 50 ) NOT NULL ,
'email' varchar( 255 ) NOT NULL ,
'imei' varchar( 20 ) NOT NULL ,
'created_at' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( 'id' ) ,
KEY 'imei' ( 'imei' )
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
Error message:
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 ''sadakin'.'gcm_users' (
'id' int( 11 ) NOT NULL AUTO_INCREMENT ,
'gcm_' at line 1
I don't find error. Help me!
Use backticks to enclose identifiers. Quotes are just for strings:
CREATE TABLE IF NOT EXISTS `sadakin`.`gcm_users` (
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`gcm_regid` text,
`name` varchar( 50 ) NOT NULL ,
`email` varchar( 255 ) NOT NULL ,
`imei` varchar( 20 ) NOT NULL ,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( `id` ) ,
KEY `imei` ( `imei` )
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
There is no need of any single quotes on column names
CREATE TABLE IF NOT EXISTS sadakin.gcm_users (
id int( 11 ) NOT NULL AUTO_INCREMENT ,
gcm_regid text,
name varchar( 50 ) NOT NULL ,
email varchar( 255 ) NOT NULL ,
imei varchar( 20 ) NOT NULL ,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( id ) ,
KEY imei ( imei )
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
You have to use back-ticks instead of single quotes. Quotes are used for string literals.
Check this: http://dev.mysql.com/doc/refman/5.0/en/string-literals.html
A string is a sequence of bytes or characters, enclosed within either
single quote (“'”) or double quote (“"”)
Try:
CREATE TABLE IF NOT EXISTS `sadakin`.`gcm_users` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`gcm_regid` TEXT,
`name` VARCHAR( 50 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`imei` VARCHAR( 20 ) NOT NULL ,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( `id` ) ,
KEY `imei` ( `imei` )
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;

Syntax error in create table query

I cant get this syntax 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 '(id) ENGINE=MyISAM)' at line 15
CREATE TABLE IF NOT EXISTS `destination_cdr` (
`id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT ,
`calldate` DATETIME NOT NULL ,
`source` VARCHAR( 80 ) NOT NULL ,
`destination` VARCHAR( 80 ) NOT NULL ,
`account_code` VARCHAR( 30 ) DEFAULT NULL ,
`pincode` VARCHAR( 45 ) NOT NULL ,
`duration_call` BIGINT( 20 ) NOT NULL DEFAULT '0',
`duration_talk` BIGINT( 20 ) NOT NULL ,
`disposition` VARCHAR( 255 ) NOT NULL ,
`clid` VARCHAR( 80 ) DEFAULT NULL ,
`cdr_id` BIGINT( 20 ) DEFAULT NULL ,
`vxcdr_id` BIGINT( 20 ) DEFAULT NULL ,
`provider` INT( 11 ) NOT NULL DEFAULT '0' PRIMARY KEY ( `id` )) ENGINE = MYISAM
;
You need a commma between provider and primary Key:
`provider` INT( 11 ) NOT NULL DEFAULT '0', PRIMARY KEY ( `id` )) ENGINE = MYISAM
Missing comma before primary key clause.
`provider` INT( 11 ) NOT NULL DEFAULT '0', PRIMARY KEY ( `id` ))
Error
SQL query:
--
-- Database: wadud
--
-- Table structure for table destination
CREATE TABLE destination (
id bigint(20) NOT NULL,
country varchar(255) NOT NULL,
photo text NOT NULL,
tours varchar(255) NOT NULL,
created_at timestamp NULL DEFAULT NULL,
updated_at timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
MySQL said: Documentation
1050 - Table 'destination' already exists

mysql 1064 error ou have an error in your SQL syntax;

creating a table in phpmyadmin it shows following error![enter image description here][1]
Error
SQL query:
CREATE TABLE `user` (
`usrID` BIGINT( 11 ) NOT NULL ,
`name` VARCHAR( 100 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL ,
`mobile` VARCHAR( 10 ) NOT NULL ,
`gender` CHAR( 10 ) NOT NULL ,
`countryID` INT( 11 ) NULL ,
`stateID` INT( 11 ) NULL ,
`cityID` INT( 11 ) NULL ,
`pincode` VARCHAR( 6 ) NULL ,
`place` VARCHAR( 100 ) NULL ,
`address` VARCHAR( 200 ) NULL ,
`usertype` VARCHAR( 5 ) NULL ,
`pass` VARCHAR( 20 ) NULL ,
`edate` DATETIME NULL ,
`eusrID` INT( 11 ) NULL ,
`busrID` INT( 11 ) NULL ,
`adminID` INT( 11 ) NULL ,
`active` SET( 1 ) NOT NULL
) ENGINE = innodb
MySQL said: Documentation
#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 '1) NOT NULL) ENGINE = innodb' at line 1
The value of 1 should be wrap with single quote. See here for details.
`active` SET( '1' ) NOT NULL
SQLFiddle Demo
SET takes a number of possible string values for the column, for example;
`color` SET('red', 'green', 'blue')
This would mean that the column could have the values 'red', 'red,blue', 'red,green,blue' etc.
Your definition;
`active` SET(1)
doesn't really make any sense. Either you're looking for a boolean flag (INT(1)) or you need to list the possible values the field can have. Note that SET('yes','no') would allow all of the values 'yes', 'no' and 'yes,no' (the combination), which may not be the best choice for an active flag.

#1064 - You have an error in your SQL syntax; [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
I am getting the following error whenever I want to create a table in MySQL.
#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 '( 32 ) NOT NULL DEFAULT CURRENT_TIMESTAMP , `visitor_day` SMALLINT( 2 ) NOT NUL' at line 7
code:
CREATE TABLE `visitors_table` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visitor_ip` VARCHAR( 32 ) NULL ,
`visitor_browser` VARCHAR( 255 ) NULL ,
`visitor_hour` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_date` TIMESTAMP( 32 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`visitor_day` SMALLINT( 2 ) NOT NULL ,
`visitor_month` SMALLINT( 2 ) NOT NULL ,
`visitor_year` SMALLINT( 4 ) NOT NULL ,
`visitor_refferer` VARCHAR( 255 ) NULL ,
`visitor_page` VARCHAR( 255 ) NULL
) TYPE = MYISAM ;
Couple of errors fixed here:
CREATE TABLE `visitors_table` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visitor_ip` VARCHAR( 32 ) NULL ,
`visitor_browser` VARCHAR( 255 ) NULL ,
`visitor_hour` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`visitor_day` SMALLINT( 2 ) NOT NULL ,
`visitor_month` SMALLINT( 2 ) NOT NULL ,
`visitor_year` SMALLINT( 4 ) NOT NULL ,
`visitor_refferer` VARCHAR( 255 ) NULL ,
`visitor_page` VARCHAR( 255 ) NULL
) ENGINE = MYISAM ;
TIMESTAMP does not support precision. Not until MySQL 5.6, that is, where sub-second resolution is possible.
Remove the ( 32 ) from the TIMESTAMP definition.
TIMESTAMP does not have a size and you should use engine instead of type
CREATE TABLE `visitors_table` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visitor_ip` VARCHAR( 32 ) NULL ,
`visitor_browser` VARCHAR( 255 ) NULL ,
`visitor_hour` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`visitor_day` SMALLINT( 2 ) NOT NULL ,
`visitor_month` SMALLINT( 2 ) NOT NULL ,
`visitor_year` SMALLINT( 4 ) NOT NULL ,
`visitor_refferer` VARCHAR( 255 ) NULL ,
`visitor_page` VARCHAR( 255 ) NULL
) engine = MYISAM ;