如何查询确定行数,不足的用指定字符补齐

使用场景

我们在做报表的时候,经常遇到这种情况:表格行数固定,用户输入的行数不确定,空白的地方需要用指定字符补齐,如:

如何用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;
posted @ 2020-02-11 18:19  fight139  阅读(299)  评论(0编辑  收藏  举报