union 正在合并结果
我有一个如下所示的查询:
(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请改用
UNION ALL
。Use
UNION ALL
instead.保留重复结果
preserved duplicate results