在用Doobie编写以下查询时:
(SELECT id FROM (VALUES(?),(?),(?)) table(id))
UNION
SELECT id FROM table我有数据列表,例如列表(1,2,3,4),即可变大小的。如何使用Doobie将值列表插入到SQL values子句中?
发布于 2019-01-03 09:37:59
嗨,你可以参考下面的参考从多比官方社区网页:
Consider a below table DDL:
CREATE TABLE country (
code character(3) NOT NULL,
name text NOT NULL,
population integer NOT NULL,
gnp numeric(10,2)
-- more columns, but we won't use them here
)使用doobie语法的SQL,其中代码是可变大小的列表:
sql"""
select code, name, population, gnp
from country
where code in (${codes : codes.type})
""".query[Country]https://stackoverflow.com/questions/50574838
复制相似问题