2

有人可以帮我纠正我在尝试运行 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 'WHERE user_id = '3' AND id = '3' AND friendship_status = '0'' at line 2

这是我的mysql代码。

SELECT users_friends.*
WHERE user_id = '$user_id'
AND id = '$request_id'
AND friendship_status = '0'
4

2 回答 2

4

可能需要添加:FROM users_friends就在WHERE.

SELECT  users_friends.*
FROM    users_friends
WHERE   user_id = '$user_id'
AND     id = '$request_id'
AND     friendship_status = '0'
于 2010-07-10T07:07:19.327 回答
0

试试这个

(假设为 PHP)

 $string = "SELECT from  database_name.table_name 
            WHERE user_id ='".$user_id."' AND id= '".$request_id."'
            AND friendship status ='0' ";

我假设$user_id并且$request_idvarchar/text类型

于 2010-07-10T07:11:02.210 回答