"""select distinct "data" from (select * from "DemoName" inner join "patient" on "DemoName"."rowid" = "patient"."rowid" where "patient"."name" LIKE '%$pattern%' and length('$pattern') <= length("patient"."name") and "patient"."archived" = 'false'
union
select * from "DemoName" inner join "patient" on "DemoName"."rowid" = "patient"."rowid" where "DemoName"."word" match '$pattern*' and "patient"."archived" = 'false' and score < 800 and top = 30
) ORDER BY CASE WHEN name LIKE '$pattern%' THEN 0 WHEN name LIKE '%$pattern%' THEN 1 ELSE score END LIMIT 80""".trimIndent()
这是我用于搜索不同的查询。但由于联合运算符,我在此查询中得到了重复的值
您应该使用“UNION DISTINCT”而不仅仅是“UNION”。希望这会起作用:)