union 正在合并结果

发布于 2024-10-04 19:40:51 字数 318 浏览 0 评论 0原文

我有一个如下所示的查询:

(SELECT title FROM pjeducations LIMIT 5)
UNION
(SELECT title FROM pjeducations WHERE animal != "all" LIMIT 5)
UNION
(SELECT title FROM pjeducations ORDER BY price DESC LIMIT 5)

第二个选择中的一些结果与第一个选择中的结果相同,与第三个选择中的结果相同。

问题是重复的结果会自动被删除,但我希望它们保留在其中。有人知道如何实现这一目标吗?

i have a query that looks as following:

(SELECT title FROM pjeducations LIMIT 5)
UNION
(SELECT title FROM pjeducations WHERE animal != "all" LIMIT 5)
UNION
(SELECT title FROM pjeducations ORDER BY price DESC LIMIT 5)

Some of the results in the second select are the same as in the first, same with the third select.

The problem is that the duplicate results automaticly get removed but i would like them to stay in it. Anyone know how to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

变身佩奇 2024-10-11 19:40:51

请改用UNION ALL

Use UNION ALL instead.

别低头,皇冠会掉 2024-10-11 19:40:51
Union All 

保留重复结果

Union All 

preserved duplicate results

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文