Sean
Sean

Reputation: 3

getting mysql Error 1064

I am build a basic application with golang, i am using github.com/go-sql-driver/mysql driver. I am connecting to clearDB mysql on heroku but every time i'm getting

Error 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, price from product where id = ?' at line 1

I can't under stand why, this is the piece of code that i'm using for the query the product database.

   id := c.Param("id")
    row := db.QueryRow("select id, desc, price from product where id = ?;", id)
            err := row.Scan(&product.Id, &product.desc, &product.price)

Upvotes: 0

Views: 232

Answers (1)

nos
nos

Reputation: 229342

desc is a keyword so you get in trouble when you also named a column desc.

With MySQL you need to quote the name with backticks, like so:

"select id, `desc`, price from product where id = ?"

Upvotes: 1

Related Questions