0
我有一个要求,需要查询每个类型的前5个新闻并返回到前端,由JPA实现。postgreSQL分类限制
我现在已经两种解决方案,
- 一是通过注释来手动添加联合SQL,
- 呼叫通过循环不同参数类型的服务。
其实我要的是就像SQL如下
select id, title, content
from portal p
where p.type = 'NEWS'
order by create_date
limit 5
union
select id,title,content,
from portal p
where p.type = 'MAG'
order by create_date
limit 5
union...
解决方案,需要对代码JAVA许多SQL语句,而溶液B是不是有效,因为类型超过10
有没有其他的方式来查询数据?通过注释或PostgreSQL函数?我是JPA & Postgres的新手。
在此先感谢。
是的......我忘了分区。谢谢 :) –