Dinesh Tanwar
Dinesh Tanwar

Reputation: 41

Cannot find MySQL syntax error

MySQL gives me syntax error for a simple query but I don't see any error. If you guys find any please help.

insert into cast(sid,celeb_id,type,name,prior)
  values(30,1,1,'James Keziah Delaney',2)

It gives sql syntax error near cast.

Upvotes: 2

Views: 66

Answers (2)

D-Shih
D-Shih

Reputation: 46219

The main cause of this error is that there is a function Cast in mysql.

It look like to call the cast() function.

You can choose one of the solutions to solve it.

  1. add ` to contain cast table name

look like this.

insert into `cast`(sid,celeb_id,type,name,prior) values(30,1,1,'James Keziah Delaney',2)

sqlfiddle

  1. add a space between cast and ( let mysql know you did't want to execute Cast method. thank for @Barmar remind.

Note:

I would suggest you don't give the table name from keyword or function name.

Upvotes: 5

Terry Carmen
Terry Carmen

Reputation: 3886

You can't insert into cast(). It requires a list of column names.

Upvotes: 0

Related Questions