sqlite union无法使用order limit

❌
select * from gif where not (used='1') and not (WEBSITE like '%qiu%mei%')  order by RANDOM() limit 9
UNION
select * from gif where not (used='1') and  (WEBSITE like '%qiu%mei%')  order by RANDOM() limit 1

✅
select * from (select * from gif where not (used='1') and not (WEBSITE like '%qiu%mei%')  order by RANDOM() limit 9)
UNION
select * from(select * from gif where not (used='1') and  (WEBSITE like '%qiu%mei%')  order by RANDOM() limit 1)
sqlite union查询中 使用 order ,limit 报错,后来经查明,可以将union 两端包裹在两个子查询中。

问题得以解决!

留下评论