Làm đẹp kết quả REPEAT()
Dùng CONCAT() thêm phân cách, hoặc QUOTE() bao quanh dấu nháy.
Ví dụ 1: Thêm dấu * và khoảng trắng giữa các lần lặp
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* |
+-----------------------------------------+
Ví dụ 2: Kết hợp QUOTE() + CONCAT() + REPEAT()
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* ' |
+-----------------------------------------------+