【发布时间】:2015-03-05 05:55:54
【问题描述】:
如果 m.message_type_id IN () 为空,它会给我一个错误提示
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 ') ) UNION ( ' at line 16
SELECT m.id,m.log,message,images,videos,uo.user_id as to_id,owner_id,
IF(m.owner_id = 45,'sent','received') as type
FROM messages as m
LEFT JOIN events as e ON m.message_type_id = e.id
LEFT JOIN user_organization as uo ON uo.id = e.org_id
WHERE m.message_type_id IN ()
AND m.type = 'event_invite_request_msg'
如果 WHERE m.message_type_id IN (61) 它会给我正确的响应。
解决办法是什么?
【问题讨论】:
-
在 where 条件下显示你传递 id 的代码
-
$friendsArray = array(); foreach($friends as $friend){ $friendsArray[] = $friend->friend_id; } $friendsArray = implode(',',$friendsArray);
标签: php mysql codeigniter codeigniter-2 notin