我無法完成我的MySQL連接。我不確定查詢的最後部分的語法。使用我的SQL連接
我的查詢:
$posts_query= "
SELECT *
FROM posts p
JOIN relations r ON p.user_id = r.recipient
WHERE (r.status = 1 OR r.status = 2)
AND (r.sender = '".$user_id."' OR p.user_id = '".$user_id."')
// How do I write this part?
AND skip where r.status = 1 and p.privacy = 2 where p.user_id != $user_id //
ORDER BY p.post_id DESC;
";
這是什麼查詢應該做?你想做什麼? –
編寫這樣的查詢時應該非常小心,並且始終使用[正確的SQL轉義](http://bobby-tables.com/php)來避免嚴重的[SQL注入漏洞](http://bobby-tables.com /)。目前還不清楚'$ user_id'是否在這裏完全被轉義,這可能是非常糟糕的。如果您使用佔位符值,則不必擔心諸如適當的引用。 – tadman