Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
304 views
in Technique[技术] by (71.8m points)

php - Can't use column name "desc" in mysql

INSERT INTO movie (id, title, desc, released, views, featured) VALUES ('', 'title', '

    description

', '2006-12-12', '0', '0')

error is

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 'desc, released, views, featured) VALUES ('', 'title', ' description ', ' at line 1

table structure is

id [ (pk, auto_inc) int(11) ]
title [ varchar(256) ]
desc [ text ]
released [ date ]
views [ int(11) ]
featured [ int(11) ]

running in phpmyadmin sql editor

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

desc is a mysql reserved word. you must use backticks `` with the columns which are reserved words.

INSERT INTO movie (id, title, `desc`, released, views, featured)...

You should avoid using reserved words as column name or must use backticks (``)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...