如何查询确定行数,不足的用指定字符补齐
使用场景
我们在做报表的时候,经常遇到这种情况:表格行数固定,用户输入的行数不确定,空白的地方需要用指定字符补齐,如:
如何用mysql实现?
SELECT
taskNo,a4,orderNo
FROM
(
SELECT
taskNo,a4,orderNo
FROM
rep_ammeteroriginal t1 where orderNo in(1)
UNION all SELECT '此栏一下空白',NULL,NULL FROM rep_ammeteroriginal t3 limit 1
UNION all SELECT NULL,NULL,NULL FROM rep_ammeteroriginal t3
UNION all SELECT NULL,NULL,NULL FROM rep_ammeteroriginal t3
UNION all SELECT NULL,NULL,NULL FROM rep_ammeteroriginal t3
UNION all SELECT NULL,NULL,NULL FROM rep_ammeteroriginal t3
) t2
LIMIT 5;