如何将另一个MySQL函数与REPEAT()函数一起使用?
假设如果要使REPEAT()函数的输出更具可读性,则可以将另一个函数与它一起使用。例如,如果要在重复值之间添加空格或其他字符,则可以使用CONCAT()function。
示例
mysql> Select REPEAT(CONCAT(' *',Subject,'* '),3)AS Subject_repetition from student;
+-----------------------------------------+
| Subject_repetition |
+-----------------------------------------+
| *Computers* *Computers* *Computers* |
| *History* *History* *History* |
| *Commerce* *Commerce* *Commerce* |
| *Computers* *Computers* *Computers* |
| *Math* *Math* *Math* |
+-----------------------------------------+
5 rows in set (0.00 sec)在下面的示例中,我们同时使用QUOTE()和CONCAT()函数一起使用REPEAT()function:
mysql> Select REPEAT(QUOTE(CONCAT(' *',Subject,'* ')),3)AS Subject_repetition from student;
+-----------------------------------------------+
| Subject_repetition |
+-----------------------------------------------+
| ' *Computers* '' *Computers* '' *Computers* ' |
| ' *History* '' *History* '' *History* ' |
| ' *Commerce* '' *Commerce* '' *Commerce* ' |
| ' *Computers* '' *Computers* '' *Computers* ' |
| ' *Math* '' *Math* '' *Math* ' |
+-----------------------------------------------+
5 rows in set (0.00 sec)这样,通过将其他函数与REPEAT()函数一起使用,我们可以使输出更具可读性。
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短