我无法让它工作。我想将此查询转换为 UNION 以删除 OR innotifies
的 INNER JOIN。
SELECT posts.status, posts.reports, posts.private_id,
enter code hereposts.parent_id, posts.post_id,
posts.reply_counts, posts.sender, posts.content,
posts.image, posts.thumb, posts.date,members.username,
members.avatar,members.avatar_path,members.level, members.state
FROM posts
INNER JOIN members ON posts.sender = members.member_id
INNER JOIN notifies ON (
posts.post_id=notifies.post_id OR posts.parent_id=notifies.post_id
)
WHERE (posts.date>notifies.last_date AND posts.sender<>1)
AND notifies.member_id=1
AND posts.private_id<>0
AND posts.status=1
AND posts.reports<3
ORDER BY posts.last_update DESC, posts.date DESC LIMIT 0,25;
我的尝试不起作用:
(SELECT posts.status, posts.reports, posts.private_id , posts.parent_id,
posts.post_id, posts.reply_counts, posts.sender, posts.content,
posts.image, posts.thumb, posts.date, members.username, members.avatar,
members.avatar_path,members.level, members.state
FROM posts
INNER JOIN members ON posts.sender = members.member_id
INNER JOIN notifies ON posts.parent_id=notifies.post_id)
UNION
(SELECT posts.status, posts.reports, posts.private_id , posts.parent_id,
posts.post_id, posts.reply_counts, posts.sender, posts.content,
posts.image, posts.thumb, posts.date, members.username, members.avatar,
members.avatar_path,members.level, members.state
FROM posts
INNER JOIN members ON posts.sender = members.member_id
INNER JOIN notifies ON posts.post_id=notifies.post_id)
WHERE (posts.date>notifies.last_date AND posts.sender<>1)
AND notifies.member_id=1
AND posts.private_id<>0
AND posts.status=1
AND posts.reports<3
ORDER BY posts.last_update DESC, posts.date DESC LIMIT 0,25;