2010-07-10 153 views
1

有人可以幫我糾正我試圖運行我的MySQL查詢時得到的以下錯誤。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' 
+3

哪裏是'SELECT'後'from'? – 2010-07-10 07:07:25

+0

嗯,我只是注意到我的錯誤,謝謝。不要在深夜編碼 – 2010-07-10 07:08:41

回答

4

大概需要添加:FROM users_friends只是WHERE之前。

SELECT users_friends.* 
FROM users_friends 
WHERE user_id = '$user_id' 
AND  id = '$request_id' 
AND  friendship_status = '0' 
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類型的