Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace dot with comma on SELECT

Tags:

mysql

I would like to replace any 'dot' character in my query string, on SELECTing fields from database.

I'll need to modify lots of queries, I'm willing there's a function that will work to all columns on SELECT. I mean something like this SELECT DOT_TO_COMMA(*) FROM...

Right now what I have:

SELECT price, lastprice FROM products

OUTPUT: 22.10, 5.24

EXPECTATION: 22,10, 5,25

like image 773
user1876234 Avatar asked Jun 05 '14 09:06

user1876234


1 Answers

SELECT REPLACE(price, '.', ',') AS price
FROM products;
  • read more about it here

You have to wrap each column you need to replace with the function. Using replace(*) is not possible.

like image 136
fancyPants Avatar answered Sep 21 '22 21:09

fancyPants