我有这段代码:
static public function getLastNewMessage($profile_id)
{
$c = new Criteria();
$subSelect = "rc_message_box_table.profile_id_from NOT IN ( SELECT rc_blocklist_table.profile_id_block FROM rc_blocklist_table WHERE profile_id = $profile_id ) and rc_message_box_table.profile_id_to=$profile_id and opened_once = 0";
$c->add(self::PROFILE_ID_TO, $subSelect, Criteria::CUSTOM);
$c->addAsColumn("lastRow", MAX(self::ID));
//$subSelect2 = "max(rc_message_box_table.id)";
//$c->add(self::ID, $subSelect2, Criteria::CUSTOM);
return self::doSelect($c);
}
并收到此错误:
500 | Internal Server Error | PropelException [wrapped: SQLSTATE[42000]: Syntax error or access violation: 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 'AS lastRow FROM rc_message_box_table` WHERE rc_message_box_table.profile_id_fro' at line 1]
我只想在rc_message_box_table上记录MAX(自动增量字段),这个字段是ID 我已经尝试了注释掉的线条,但没有任何作用。我不知道如何实现这一点..请帮忙吗? 谢谢
答案 0 :(得分:0)
你的SQL中有一个额外的`,它来自哪里?它紧挨着:
AS lastRow FROM rc_message_box_table`