Alex
Alex

Reputation: 170

Insert additional text into table fields

I export a CSV-File with shipping weights from my webshop. The problem is there are bulk numbers and no unit Like this:

+------+------+
| ID   |weight|
+------+------+
| 101  | 1,2  |
+------+------+
| 102  | 2,5  |
+------+------+

But I need a result like this:

+------+------+
| ID   |weight|
+------+------+
| 101  |1,2 kg|
+------+------+
| 102  |2,5 kg|
+------+------+

This is the statement:

SELECT id_product AS `ID`, weight AS `weight` FROM products

Is it possible to add a string ('kg') into the SELECT statement or something of a kind? Or are there other possible solutions? (The system works with SELECT only)

Upvotes: 1

Views: 42

Answers (2)

Jim Macaulay
Jim Macaulay

Reputation: 5141

Please use below query,

SELECT id_product AS `ID`, weight || ' Kg' AS `weight` FROM products

You can also use CONCAT() function instead.

Upvotes: 0

Charanjeet Singh
Charanjeet Singh

Reputation: 310

Please try the below query.

SELECT id_product AS `ID`, CONCAT(weight ,' kg') AS `weight` FROM products

Hope will help you

Upvotes: 3

Related Questions