我有一个令我困惑的 MySQL 查询。我试图从两个不同的表(blurbs 和 users)中获取特定的信息,同时将其限制为仅关注的人。
我有以下查询:
SELECT DISTINCT blurbs.text, blurbs.timestamp, users.name,
users.username, users.profilepic, users.id
FROM blurbs,users
LEFT OUTER JOIN follows
ON blurbs.uid = follows.following AND follows.follower = ?
WHERE (blurbs.uid = $user_id OR follows.following IS NOT NULL)
AND (LOWER(blurbs.text) LIKE '%$query%' OR LOWER(users.name) LIKE '%$query%')
AND blurbs.is_private=0 AND blurbs.uid=users.id
LIMIT 0,30
它工作不正常,但由于连接,我变得过于困惑。
我应该怎么做才能解决这个问题?