mysqlprefix

MySQL - add text prefix before column name in SELECT statement


Here is my table:

| ID | NUMBER |
| 1  |  523   |
| 2  |  293   |
| 3  |  948   |

And now, I want to get all NUMBER values but I want to add in result two numbers - 48 - (without upadting existing results). So finally I want print these results:

| NUMBER   |
|  48523   |
|  48293   |
|  48948   |

So I need a query, something like this:

SELECT '48' + `number` FROM `table`

but this query doesn't work fine (this query only update column name from NUMBER to 48 + NUMBER). Any ideas?

Thanks.


Solution

  • You need CONCAT

    SELECT CONCAT('48' , `number`) AS number FROM table
    

    Demo