a column called "desc"
Hey -- I'm currently working my way through Mr. Yank's PHP/MySQL book and jumped in tonight.
I was in the process of creating my very first table and kept running into an error message. I wanted to call one of the columns "desc" as in short for description but I kept getting a syntax error. So I played with it and thought, OK, I'll rename it "tell." Well, sure enough "tell" worked while "desc" produced syntax errors. How come?
These were nothing but simple TEXT columns.
Sounds like you need a good MySQL tutorial. :) "DESC" is a reserved keyword in SQL. It is an abbreviation for DESCENDING, which is used in ORDER BY statements.
DESC is a reserved word for descending when you are ordering your columns highest to lowest value hence the error.
Dang, beat by seconds!
you need something like...
SELECT * FROM blah WHERE `desc` = 'Hello'
Yes bluesaga, you are right, you can use backquotes. Better practice though it to rename a column named with a reserved word. Sooner or later those backticks are going to be forgotten.