使用 Where 条件连接随机结果

Concatenate Random Result with Where Condition

我想连接来自同一个 table;

的 2 个 Select 查询的结果

我的 table :

CREATE TABLE "books" (
"id"    INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
"book_title"    TEXT UNIQUE,
"Book_desc" TEXT,
"category"  TEXT)

第一个查询:Select * from books where id = 2

第二个查询:Select * from books where id != 2 order by random() limit 3

我希望 id=3 成为结果中的第一行,我尝试了很多联合查询但没有成功。

这是我到目前为止所做的:

http://sqlfiddle.com/#!9/4ee515/3

获取 50 个随机行而不包含 id=100 行的第二个查询应该是:

select *
from (select * from table1 where id <> 100  order by random() limit 50) 

所以使用UNION ALL和条件排序:

select *
from (
  select * from table1 where id = 100
  union all
  select *
  from (select * from table1 where id <> 100  order by random() limit 50) 
)
order by id = 100 desc