查询中的SQL语法错误

时间:2012-07-25 16:01:48

标签: mysql sql

我的MySQL查询显示错误有什么问题:

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 'index WHERE id=1' at line 1

相关代码:

$qu = mysql_query("SELECT * FROM index WHERE id= 1") or die("MySQL ERROR: ".mysql_error());

    WHILE($d = mysql_fetch_array($qu)):

    $con = $d['content'];

endwhile;

1 个答案:

答案 0 :(得分:7)

indexMySQL reserved keyword,所以你必须用这样的反引号引用它:

SELECT * 
FROM `index` 
WHERE id = 1