$sql1= "CREATE TABLE bookapp(
id int NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
pnumber int(11),
emailID VARCHAR(50),
reg_date datetime()
PRIMARY KEY(id)
)";
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 ''', NULL)' at line 1
You can use the following to create the table:
CREATE TABLE bookapp(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
pnumber INT(11),
emailID VARCHAR(50),
reg_date DATETIME,
PRIMARY KEY(id)
);
Explanation:
( and ) on DATETIME is invalid. DATETIME doesn't need a length.
You have to seperate the column definitions with ,. You forgot this after column reg_date.
Hint (to your error message):
Your given CREATE TABLE throws another error message, that is different to yours:
Error Code: 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 ') PRIMARY KEY(id) )' at line 6
Related
So I have this:
CREATE TABLE activeSessions (
id VARCHAR NOT NULL UNIQUE,
claimtime int,
mp FLOAT
);
When I put this into the database, this comes up:
#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 UNIQUE,
claimtime int,
mp FLOAT
)' at line 2
How do I fix this?
You need to specify the constraint after the column declaration:
CREATE TABLE activeSessions (
id VARCHAR(10) NOT NULL,
claimtime int,
mp FLOAT,
UNIQUE(id)
);
Remember to give an INT value to the VARCHAR column.
I am trying to upload this file to netbeans however I am unable to create the authors table and continue to receive the following error:
CREATE TABLE authors (
authorID INT NOT NULL GENERATED ALWAYS AS IDENTITY,
firstName varchar (20) NOT NULL,
lastName varchar (30) NOT NULL,
PRIMARY KEY (authorID)
);
INSERT INTO authors (firstName, lastName)
VALUES
('Paul','Deitel'),
('Harvey','Deitel'),
('Abbey','Deitel'),
('Dan','Quirk'),
('Michael','Morgano');
[Warning, Error code 1,064, SQLState 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 'GENERATED ALWAYS AS IDENTITY,
firstName varchar (20) NOT NULL,
lastName va' at line 2
[Exception, Error code 1,064, SQLState 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 'GENERATED ALWAYS AS IDENTITY,
firstName varchar (20) NOT NULL,
lastName va' at line 2
Line 2, column 1
[Warning, Error code 1,146, SQLState 42S02] Table 'books.authors' doesn't exist
I have been searching all over the web for hours and have yet to find an answer! I am new to SQL so I apologize if this is a duplicate question. I am using MYSQL version 5.7.18
There are seval things wrong:
identity is SQL Server syntax, MySQL uses auto_increment
<name> <type> generated always as <calculation> applies to calculated columns.
Try:
CREATE TABLE authors (
authorID INT NOT NULL AUTO_INCREMENT,
firstName varchar (20) NOT NULL,
lastName varchar (30) NOT NULL,
PRIMARY KEY (authorID)
);
I try to create a table in MySQL:
mysql> create table order ( ID varchar(30) not null,
-> Cname varchar(100) not null,
-> name varchar(30),
-> Type varchar(30),
-> primary key(ID, Cname));
but an error occured:
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 'order ( ID varchar(30) not null, Cname
varchar(100) not null, name varchar(30), ' at line 1
I have checked for thousand time and I still find no error here.
Can anyone help me?
Its is because of the table name order.
There is an order by reserved word. Change the table name and it will work fine.
If you want order as table name use back ticks around the table name. It will workfine
I have the following query for creating a table in my database but I am getting an error:
CREATE TABLE student (
accountNumber INT NOT NULL PRIMARY KEY,
firstName CHAR(20),
lastName CHAR(20),
courseID VARCHAR(6),
grade DOUBLE(3)
)
The error I am getting is:
ERROR 1064 (42000): 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 '))' at line 1
You dont need NOT NULL if declaring a Primary Key...because that key always needs to be available
When trying to create this table, it doesn't want to work properly though it worked minutes before? Assume that $username is equal to "Test" for brevity.
The error I'm receiving is:
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(10) INT AUTO_INCREMENT, PRIMARY KEY(id), message
varchar(250), ' at line 2
This is the code I'm currently using:
$sql = "CREATE TABLE {$username}
(
id(10) INT AUTO_INCREMENT,
PRIMARY KEY(id),
message varchar(250),
sender varchar(100)
)";
You have a SQL syntax error.
Instead of id(10) INT AUTO_INCREMENT
It should be id INT(10) AUTO_INCREMENT