Integer to character count for simple graph?

时间:2015-07-13 21:02:04

标签: mysql

Is there an expression I can use to convert integers to a count of characters, for simple graphing?

What I want is this:

+---+-------+
| 5 | ----- |
| 1 | -     |
| 2 | --    |
| 4 | ----  |
+---+-------+

2 个答案:

答案 0 :(得分:2)

SELECT REPEAT('-',int_column) FROM TABLE

答案 1 :(得分:1)

From the manual

mysql> SELECT REPEAT('MySQL', 3);

'MySQLMySQLMySQL'

https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_repeat ->