我想结合两个查询的结果。我使用了选择联合,但它强加了我的网站。(记录我的 php 内存限制是 128M)我如何在不强加服务器的情况下组合这些查询的结果?
第一次查询
SELECT mybb_posts.pid, mybb_posts.dateline, mybb_posts.subject, mybb_users.username, mybb_users.avatar, mybb_posts.message
FROM mybb_posts, mybb_users
WHERE mybb_posts.uid = mybb_users.uid AND mybb_posts.fid <> 170 AND mybb_posts.fid <> 77 AND mybb_posts.fid <> 96
ORDER BY mybb_posts.dateline DESC
第二次查询
SELECT ek_yorumlar.id, ek_yorumlar.zaman, ek_yorumlar.icisim, mybb_users.username, mybb_users.avatar, ek_yorumlar.turu
FROM ek_yorumlar, mybb_users
WHERE ek_yorumlar.gonderen = mybb_users.uid
ORDER BY ek_yorumlar.zaman DESC
联合查询
SELECT * FROM(
SELECT mybb_posts.pid, mybb_posts.dateline, mybb_posts.subject, mybb_users.username, mybb_users.avatar, mybb_posts.message
FROM mybb_posts, mybb_users
WHERE mybb_posts.uid = mybb_users.uid AND mybb_posts.fid <> 170 AND mybb_posts.fid <> 77 AND mybb_posts.fid <> 96
ORDER BY mybb_posts.dateline DESC
) AS T
UNION ALL
SELECT * FROM (
SELECT ek_yorumlar.id, ek_yorumlar.zaman, ek_yorumlar.icisim, mybb_users.username, mybb_users.avatar, ek_yorumlar.turu
FROM ek_yorumlar, mybb_users
WHERE ek_yorumlar.gonderen = mybb_users.uid
ORDER BY ek_yorumlar.zaman DESC
) AS T
ORDER BY dateline DESC LIMIT 25