我收到此错误:
数据库查询错误。代码:42601消息:语法错误原因:错误:“ 当我尝试执行查询时
我正在尝试从“ selected_tags”中获取包含标签最多的“节目”的“组织”。
@SqlQuery("SELECT DISTINCT organisation.id, organisation.name, organisation.type, " +
" organisation.logo_asset_id,organisation.address, organisation.status, count(s) " +
"FROM organisation " +
" LEFT JOIN channel c on organisation.id = c.organisation_id " +
" LEFT JOIN show s on c.id = s.channel_id " +
" WHERE (<selected_tags>) && s.tags " +
" GROUP BY organisation.id, organisation.name, organisation.type, " +
" organisation.logo_asset_id,organisation.address, organisation.status " +
" ORDER BY count(s) DESC " +
" LIMIT (:limit) OFFSET (:offset);")
List<Organisation> findByTags(@BindIn("selected_tags") List<String> tags, @Bind("limit") int limit, @Bind("offset") int offset);
最佳答案
似乎您正在尝试将列表与JDBI绑定,但我认为您的SQL语句不正确。
正确的应如下所示:
...
WHERE s.tags IN (<selected_tags>)
...