phpmyadmin / create table / syntax error / enum - mysql

I have searched, but frustratingly have been unable to figure out why I am getting this error on the following SQL statement.
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 ''kidney_renal_dialysis' enum('Yes','UnderTreat','No','Ref') not NULL, 'liver_c' at line 5
SQL Statement:>
CREATE TABLE `client_health_info` (
`client_id` int(11) NOT NULL PRIMARY KEY,
`ER_visits_3_months` int(2) NOT NULL,
`hospitilizations_last_year` int(2) NOT NULL,
'kidney_renal_dialysis' enum('Yes','UnderTreat','No','Ref') not NULL,
'liver_cirr_ES_liver' enum('Yes','UnderTreat','No','Ref') not NULL,
'HCAH' enum('Yes','UnderTreat','No','Ref') not NULL,
'hiv_aids' enum('Yes','UnderTreat','No','Ref') not NULL,
PRIMARY KEY (`client_id`)
) ENGINE=InnoDB not CHARSET=latin1;

You are using the wrong quotes! ;-)
CREATE TABLE `client_health_info` (
`client_id` int(11) NOT NULL PRIMARY KEY,
`ER_visits_3_months` int(2) NOT NULL,
`hospitilizations_last_year` int(2) NOT NULL,
`kidney_renal_dialysis` enum('Yes','UnderTreat','No','Ref') not NULL,
`liver_cirr_ES_liver` enum('Yes','UnderTreat','No','Ref') not NULL,
`HCAH` enum('Yes','UnderTreat','No','Ref') not NULL,
`hiv_aids` enum('Yes','UnderTreat','No','Ref') not NULL
) ENGINE=InnoDB, CHARSET=latin1;
EDIT: Fixed two further bugs: Duplicate PRIMARY KEY statement and the NOT before CHARSET.

Related

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB

CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` double(11) NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
near ') NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT
CHARSET=latin1 AUTO_INCRE' at line 5
try using float without the number of showing digit
CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` double NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
and for price could be you need a fixed decimal length so you should use decimal
CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` decimal(10,2) NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
You're missing a value in your double specifier:
`price` double(11) NOT NULL
It needs both the total digits and the digits following the decimal. Something like:
`price` double(11,2) NOT NULL
Though for currency values you may be better off using decimal instead:
`price` decimal(11,2) NOT NULL
As this uses a more fixed precision. Using a double may result in unexpected calculation results from how floating point arithmetic works.

#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 ')'

This is the code. However I kept getting this 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 ')' at line 7
Weirdly line 7 is the CREATE TABLE academicnews( line. Which does not contain ')' .
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL,
); #Line 7
Get rid of the last comma. It is unnecessary and invalid.
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL, <-- HERE
);
It should be
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL
);
You are getting this error bcoz of an addition comma.
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL, <--- This is the error
);
CREATE TABLE IF NOT EXISTS `testinfo` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`sl_no` int(10) NOT NULL,
`p1` int(3) DEFAULT NULL,
`p2` int(3) DEFAULT NULL,
`p3` int(3)DEFAULT select [p1]+[p2],
`mid` int(8) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `mid` (`mid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

Continually getting this error with my SQL code

Error says:
#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 '' at line 9
My query:
CREATE TABLE `login`.`login`(
`id` SERIAL NOT NULL,
`user` VARCHAR(20)NOT NULL,
`pass` VARCHAR(30) NOT NULL,
PRIMARY KEY(`id`),
UNIQUE(
`user`,
`pass`
)
TRY THIS
CREATE TABLE `login`(
`id` INT( 11 ) AUTO_INCREMENT NOT NULL,
`user` VARCHAR(20)NOT NULL,
`pass` VARCHAR(30) NOT NULL,
PRIMARY KEY(`id`),
UNIQUE(`user`,`pass`)
)

Why this query throwing error while inserting record

i have created one table using following query
CREATE TABLE `events` (
`event_id` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`event_name` varchar(100) NOT NULL,
`description` text,
`event_date` datetime NOT NULL,
`repeat` tinyint(4) NOT NULL,
`share` varchar(100) DEFAULT NULL,
`share_type` varchar(50) NOT NULL,
PRIMARY KEY (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
and now i am trying to insert record using this query
INSERT INTO events (username,event_name,description,event_date,repeat,share,share_type) VALUES ('bhavik','Will go home','','2012-11-11 18:10','0','','public');
error i am getting
#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 'username,event_name,description,event_date,repeat,share,share_type) VALUES ('bha' at line 1
repeat is a reserved keyword
use `repeat` in the insert statement
INSERT INTO events (username,event_name,description,event_date,`repeat`,share,share_type) VALUES ('bhavik','Will go home','','2012-11-11 18:10','0','','public');

mysql error 1064

Im trying to create a table with this code:
CREATE TABLE IF NOT EXISTS `entries` (
`id` int(10) NOT NULL auto_increment,
`atom_id` varchar(512) NOT NULL,
`title` varchar(256) NOT NULL,
`author` varchar(128) NOT NULL,
`link` varchar(512) NOT NULL,
`content` longtext NOT NULL,
`updated` varchar(25) NOT NULL,
`inserted` varchar(25) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `atom_id` (`atom_id`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `topics` (
`id` int(10) NOT NULL auto_increment,
`status` varchar(32) NOT NULL,
`hub` varchar(512) NOT NULL,
`topic` varchar(512) NOT NULL,
`lease` varchar(25) NOT NULL,
`secret` varchar(256) NOT NULL,
`token` varchar(40) NOT NULL,
`date` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
but i got this 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 ') ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1' at line 12
I can't figure what's going on, any advice?
Remove the comma after UNIQUE KEY 'atom_id' ('atom_id'), in line 11
UNIQUE KEY `atom_id` (`atom_id`),
^
Try losing the ","