Karkouch Karkouch - 3 years ago 95
SQL Question

Mysql Error while selecting row

I got an error while trying to get a row from

meta
table

mysql> SHOW CREATE TABLE 'meta';
CREATE TABLE IF NOT EXISTS `meta` (
`key` VARCHAR(255) NOT NULL,
`value` LONGTEXT NOT NULL,
UNIQUE INDEX `key_UNIQUE` (`key` ASC),
PRIMARY KEY (`key`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;

mysql> SELECT * FROM 'meta';
+---------------------+-------------+
| key | value |
+---------------------+-------------+
| website_title | title |
| website_description | description |
+---------------------+-------------+


and now when I execute this
SQL
query
SELECT value FROM 'meta' WHERE key='website_title';
I got an error.

mysql> SELECT value FROM `meta` WHERE key='website_title';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual ...the right syntax to use near 'key='website_title'' at line 1

Answer Source

key is a reserved word in MySQL. Change the column name.

Reference here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download