不懂 sql
比如我要返回 4 条记录 不符合条件的 NULL 填充
我自己瞎凑出来的功能是实现了,但是好像太复杂了,是不是有简单的办法
SELECT guild
FROM (
SELECT guild, 1 as SortOrder FROM characters WHERE id = 1
UNION SELECT NULL, 2
ORDER BY SortOrder
LIMIT 1
)
UNION ALL
SELECT guild
FROM (
SELECT guild, 1 as SortOrder FROM characters WHERE id = 2
UNION SELECT NULL, 2
ORDER BY SortOrder
LIMIT 1
)
UNION ALL
SELECT guild
FROM (
SELECT guild, 1 as SortOrder FROM characters WHERE id = 3
UNION SELECT NULL, 2
ORDER BY SortOrder
LIMIT 1
)
UNION ALL
SELECT guild
FROM (
SELECT guild, 1 as SortOrder FROM characters WHERE id = 4
UNION SELECT NULL, 2
ORDER BY SortOrder
LIMIT 1
)
1
singerll 2020-07-11 17:33:08 +08:00 via Android
题目都描述不清,没人回答你的。。
|
2
FrailLove 2020-07-11 17:44:57 +08:00 via iPhone
模拟固定 4 行数据的表 left join
|