Enum values and Error 1064 - mysql

I have a problem with this error.
here is the code to create the table
CREATE TABLE `qa`.`question`(
`id` INT(9) NOT NULL AUTO_INCREMENT,
`username` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` VARCHAR(256) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL,
`email` VARCHAR(512) NOT NULL,
`phone` INT(11) NOT NULL,
`content` TEXT NOT NULL,
`status` ENUM(0) NOT NULL,
PRIMARY KEY(`id`)
) ENGINE = InnoDB CHARSET = utf8 COLLATE utf8_general_ci;
I see the same question , but none of them occur in my code .
I think about default value too , but I receive this:
Invalid value for id (error #1067)

I can't reproduce the error you got. I got a different 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 '0) NOT NULL,
This is because the elements of an ENUM must be strings, not numbers. I changed it to:
`status` ENUM('OK', 'FAIL') NOT NULL,
and the table creation succeeded.
The error you got would happen if you tried to assign a default value to the id column, because it's also declared to use AUTO_INCREMENT. See #1067 - Invalid default value for 'bonusid' how can i fix this error?

Related

How to fix syntax error mysqli 1064 error

ım working localhost, after my work end. I want a upload my db server phpmyadmin. But still syntax error how can ı fix this?
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 '(6) NULL DEFAULT NULL,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO' at line 7 )
DROP TABLE IF EXISTS `veriler`;
CREATE TABLE `veriler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kullanici` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gpa` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`durumu` int(10) NULL DEFAULT NULL,
`miktari` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tarih` datetime(6) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
Support for fractional seconds in DATETIME values wasn't added until version MySQL 5.6. If you can't upgrade your server, you will need to remove the trailing (6) from the definition of column tarih i.e.
`tarih` datetime NULL DEFAULT NULL,
Note that you will lose precision in those values relative to your MariaDB server. If you need to store microseconds in your data values, you will need to upgrade the MySQL server to version 5.6 or later.
Try this simplified version:
CREATE TABLE `veriler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kullanici` varchar(60) DEFAULT NULL,
`gpa` varchar(255) DEFAULT NULL,
`durumu` int(10) DEFAULT NULL,
`miktari` varchar(20) DEFAULT NULL,
`tarih` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

aurora mysql 5.7 insert into failing

Can't seems to figure this one out. I come from the SQL Server world but would expect this to work the same.
insert into active_directory (ad_account,email,distinguished_name,employee_id,manager_distinguished_name,display_name,terminated)
select
ad_account,
email,
distinguished_name,
employee_id,
manager_distinguished_name,
display_name,
case when distinguished_name like '%Terminations%' then 1 else 0 end as terminated
from
active_directory_staging
fails with this 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 'terminated)
select
ad_account,
email,
distinguished_name,
employee_id,
mana' at line 1
if I remove the terminated column from the insert/select query it works fine. Add it back and it fails.
If I run just the select part (both with and without the case statement for the terminated column) it works fine.
I am probably just missing something basic here...any help is appreciated.
active_directory table create statement
CREATE TABLE `active_directory` (
`ad_account` varchar(100) COLLATE latin1_general_ci DEFAULT NULL,
`display_name` varchar(100) COLLATE latin1_general_ci DEFAULT NULL,
`email` varchar(100) COLLATE latin1_general_ci DEFAULT NULL,
`distinguished_name` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
`employee_id` varchar(100) COLLATE latin1_general_ci DEFAULT NULL,
`manager_distinguished_name` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
`terminated` bit(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
MySQL has a bunch of reserved words that can't be used as column names/ alias.
Unfortunately for this query, terminated is one such word.
Excerpt from https://dev.mysql.com/doc/refman/5.7/en/keywords.html :
...
TEMPORARY
TEMPTABLE
TERMINATED (R)
TEXT
THAN
...

Mysql i get Error when i try to edit after insert data

this is my one of database table structure and after insert some fields as row into that i can't update columns and i get error:
CREATE TABLE `channels` (
`id` int(11) NOT NULL,
`channelName` varchar(30) COLLATE utf8_persian_ci NOT NULL,
`channelLink` varchar(50) COLLATE utf8_persian_ci NOT NULL,
`channelDescription` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelImageFileName` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelAvatarFileName` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelState` tinyint(1) NOT NULL,
`channelType` enum('channels','userCreatedChannels') COLLATE utf8_persian_ci NOT NULL,
`channelOwnerUserId` int(11) NOT NULL,
`fileServerUrlId` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `channels`
--
ALTER TABLE `channels`
ADD PRIMARY KEY (`id`);
Error and notice:
This table does not contain a unique column. Features related to the grid edit, checkbox, Edit, Copy and Delete links may not work after saving.
Error
UPDATE `channels` SET `channelState` = '1' WHERE LIMIT 1
MySQL said: Documentation
#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 'LIMIT 1' at line 1
id of this table is unique and A_I, how can i resolve this problem?

mysql error 1064: after update to mysql 5.6.31 from mysql 5.5.50-cll

I am moving my website to new host, and I have this error:
Notice: 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 oc_first_page_content at line 1
Error No: 1064
SELECT content, link, background FROM `oc_first_page_content`
in /home/tiffanyd/public_html/system/library/db/mysqli.php on line 41
Notice: Trying to get property of non-object in /home/tiffanyd/public_html/catalog/controller/module/html.php on line 14
and here is the mysql code:
CREATE TABLE IF NOT EXISTS `oc_first_page_content` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` mediumtext CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL,
`content_en` mediumtext CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL,
`link` varchar(240) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL,
`background` varchar(240) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
how can fix that? :(

Incorrect Syntax created by mysql when it exported this table?

So I had a set of tables working on an older version of MySQL, however on this new version the tables it exported give a syntax error.
CREATE TABLE `joblistings` (
`jobid` int(11) NOT NULL AUTO_INCREMENT COLLATE utf8_unicode_ci NOT NULL,
`id` varchar(255) NOT NULL,
`client` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`service` tinyint(1) COLLATE utf8_unicode_ci NOT NULL,
`firstline` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`city/town/village` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`county` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`postcode` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
`daterequired` date(YYY-MM-DD) NOT NULL,
`timefrom` time(HH:MM),
`timeto` time(HH:MM),
PRIMARY KEY (`jobid`),
UNIQUE KEY `id` (`jobid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10 ;
ERROR 1064 (42000): 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 '(YYY-MM-DD) NOT NULL, `timefrom` time(HH:MM),
`timeto` time(HH:MM), PRIMARY ' at line 10
These 3 seem to be the problem, from what I understand, however I am not versed well enough in versions and changes to see a way of fixing this.
`daterequired` date(YYY-MM-DD) NOT NULL,
`timefrom` time(HH:MM),
`timeto` time(HH:MM),
Any help would be much appreciated, keeping this format is important for my system to function.
You cannot change the format of the date and time. It will be stored in the default format('YYYY-MM-DD HH:MM:SS'). You can refer the documentation for more details.
The SQL Fiddle Demo after setting it to default format.
If you want to get the output in some other format then you have to use the DATE_FORMAT() function to get it in your required format.