1

Here is the mysql code. I can't find the error here. when I execute this bunch of code it shows syntax error.

 CREATE TABLE Movie(
-> title            varchar(100),
-> year             int,
-> length           int,
-> inColor          BIT(1),
-> studioName       varchar(50),
-> producerC#       int,
-> PRIMARY KEY      ('title'));
2
  • 1
    The title column should not be between single quotes. Commented Jul 5, 2017 at 5:28
  • I would recommend removing the # from the column producerC#, it's a non standard character and may cause problems further down the line. Commented Jul 5, 2017 at 6:19

3 Answers 3

2

Try this. You have quotes in the primary key!

CREATE TABLE `movie` (
  `title` VARCHAR(100),
  `year` INT(11),
  `length` INT(11),
  `inColor` BIT(1),
  `studioName` VARCHAR(50),
  `producerC#` INT(11),
  PRIMARY KEY (`title`)
)
Sign up to request clarification or add additional context in comments.

1 Comment

+1 to counterbalance -1. This answer is clearer than the other as it explains where the problem comes from.
1

You can use below query to create table:

CREATE TABLE Movie(
title VARCHAR(100) PRIMARY KEY,
year INT,
length INT,
inColor BIT(1),
studioName VARCHAR(50),
producerC# int
) 

Comments

0
CREATE TABLE `movie` (
  `title` VARCHAR(100),
  `year` INT(11),
  `length` INT(11),
  `inColor` BIT(1),
  `studioName` VARCHAR(50),
  `producerC#` INT(11),
  PRIMARY KEY (`title`)
)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.