1. 程式人生 > >jpa執行原生sql union bug解決

jpa執行原生sql union bug解決

@Query(value = "SELECT * FROM count_entity where id=-1111 union (SELECT * FROM count_entity where video_name = ?1 AND platform ='騰訊視訊' ORDER BY click_date DESC LIMIT ?2)"
+ "UNION"
+ "(SELECT * FROM count_entity where video_name = ?1 AND platform ='愛奇藝' ORDER BY click_date DESC LIMIT ?2)"
+ "UNION"

+ "(SELECT * FROM count_entity where video_name = ?1 AND platform ='芒果TV' ORDER BY click_date DESC LIMIT ?2)", nativeQuery = true)

union前面需要連線一個空資料查詢,因為union 第一個查詢不能用()