错误1064:您的SQL语法中出现错误,要在第1行的'AND status ='1'附近使用

时间:2012-06-06 14:35:07

标签: mysql syntax-error mysql-error-1064

如何解决此错误?

SELECT user_id, CONCAT(firstname, ' ', lastname) AS fullname FROM user AND status = '1' in .../database/mysql.php on line 49

这是实际代码:

$query = $this->db->query("SELECT user_id, CONCAT(firstname, ' ', lastname) AS fullname FROM " . DB_PREFIX . "user " . $except . " AND status = '1'");

我已检查过这些字段,我的所有用户在其个人资料中都有姓/名。

2 个答案:

答案 0 :(得分:0)

你需要一个where子句 - 而不仅仅是以AND

开头
$query = $this->db->query("SELECT user_id
, CONCAT(firstname, ' ', lastname) AS fullname 
FROM " . DB_PREFIX . "user " . $except . " 
WHERE status = '1'");

答案 1 :(得分:0)

尝试将 AND 替换为 WHERE - 我认为这会做你要做的事情