我收到此错误: 数据库查询错误。代码:42601 消息:syntax_error 原因:错误:“<”处或附近的语法错误, 当我尝试执行查询时
我正在尝试从“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 绑定(bind),但我认为您的 SQL 语句不正确。
正确的应该如下所示:
...
WHERE s.tags IN (<selected_tags>)
...
关于java - 数据库查询错误。代码 : 42601 Message: syntax_error Cause: ERROR: syntax error at or near "<",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58721585/