Why is there an Statment Error in MySQL [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 6 years ago.
Improve this question
I have following Statment in MySQL and become every time this error(Screenshot):
CREATE TABLE orderstatus
(
OStatusID int NOT null PRIMARY KEY AUTO_INCREMENT,
OStatus varchar(30) null
(
I dont know why I become this error
Can you help me, please?
enter image description here

the close bracket is wrong, it should be ')'

try this
CREATE TABLE orderstatus
(
OStatusID int NOT null PRIMARY KEY AUTO_INCREMENT,
OStatus varchar(30) null
)

Below is right code Tested Successfully..
CREATE TABLE orderstatus
(
OStatusID int NOT null PRIMARY KEY AUTO_INCREMENT,
OStatus varchar(30) null
)[enter image description here][1]

Related

Why does my SQL gave an error when i am using VARCHAR as primary key? [closed]

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 1 year ago.
Improve this question
This is my code
CREATE TABLE mactor(
pid VARCHAR(30) UNSIGNED NOT NULL AUTO_INCREMENT,
fname VARCHAR(30) NOT NULL,
lname VARCHAR(30) NOT NULL,
gender VARCHAR(20) NOT NULL,
PRIMARY KEY (pid));
and this is the error
#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 'UNSIGNED NOT null AUTO_INCREMENT,
fname VARCHAR(30) NOT NULL,
lname...' at line 2.
I am very confused and I don't want to use any other values as my primary key other than VARCHAR. please help!
Remove the UNSIGNED; unsigned can only apply to numeric types, not character or binary types. You will also need to get rid of AUTO_INCREMENT; you can't auto increment a character type.

What is wrong with this Create Table statement [closed]

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 6 years ago.
Improve this question
please could you help me with this piece of code, I don't know what's wrong with it. It seems correct at simple glance but it just gets me #1064 syntax error. The MySQL version am running is 5.5
CREATE TABLE mytablename(
-> id SMALLINT NOT NULL AUTO_INCREMENT,
-> name VARCHAR(100) NOT NULL,
-> submission_date NOT NULL TIMESTAMP,
-> PRIMARY KEY (id)
-> )ENGINE=InnoDB;
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 SMALLINT NOT NULL AUTO_INCREMENT, -> name CHAR(100), ->
submission' at line 2
Remove those arrows and try escaping the column names with backticks:
CREATE TABLE mytablename(
`id` SMALLINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`submission_date` NOT NULL TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;

MYSQL SELECT statements [closed]

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 6 years ago.
Improve this question
I made a table and I want to select certain data from the table using select statements.
I want to see all the book titles that were published in May.
How can I go about doing this?
Here is the table
CREATE TABLE titles
(
title_id CHAR(3) NOT NULL,
title_name VARCHAR(40) NOT NULL,
type VARCHAR(10) ,
pub_id CHAR(3) NOT NULL,
pages INTEGER ,
price DECIMAL(5,2) ,
sales INTEGER ,
pubdate DATE ,
contract SMALLINT NOT NULL,
CONSTRAINT pk_titles PRIMARY KEY (title_id)
)ENGINE = InnoDB;
I tried this:
SELECT * FROM titles
WHERE pubdate LIKE '%%%%-05-%%';
It displays the whole column, how can I get it to only display the books title?
Try this:
SELECT title_name FROM titles WHERE MONTH(pubdate) = '5'

How can i turn a INT to VARCHAR in SQL [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm working on a database for my database class.
I have been trying to change the INT from SUBJECT_ID to VARCHAR.
This is the code I have been using but it keeps giving me errors:
ALTER TABLE COURSE
ALTER COLUMN SUBJECT_ID VARCHAR(11);
I also tried this:
SELECT CONVERT(VARCHAR(11),SUBJECT_ID) FROM COURSE;
and this is the table I'm working with:
CREATE TABLE COURSE
(COURSE_ID INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
SUBJECT_ID INT(11) NOT NULL,
COURSE_GRADE_LEVEL CHAR(2) NOT NULL,
FAC_ID INT NOT NULL,
FOREIGN KEY(FAC_ID) REFERENCES FACULTY(FAC_ID));
Any suggestions will be appreciated. Thanks.
Try:
ALTER TABLE COURSE MODIFY SUBJECT_ID VARCHAR(11);
select cast(subject_id as varchar(11)) as subject_id_str from course

syntax error in SQL statement (create table if not exists) [closed]

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
CREATE TABLE IF NOT EXISTS ax_storage
(PID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(PID),
Playername VARCHAR(32),
Time INT(10), Type INT(6),
World VARCHAR(32);
What is wrong with this SQL statement?
You are missing to close a paranthesis at the end of the query
CREATE TABLE IF NOT EXISTS ax_storage
(
PID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(PID), Playername VARCHAR(32),
Time INT(10),
Type INT(6),
World VARCHAR(32)
); -- <- you were missing this one
you forgot ) in the end of query
CREATE TABLE IF NOT EXISTS ax_storage (PID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(PID), Playername VARCHAR(32), Time INT(10), Type INT(6), World VARCHAR(32));