Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove commas of integer from MY SQL select query

Tags:

mysql

I am using a mySQL statement that returns me average of values as comma separated integer.

Eg : 2,109. But I want my output to be plain integer like 2109. Please help me on this.

like image 495
Poppy Avatar asked Jan 24 '14 15:01

Poppy


People also ask

How do I remove comma separated values in MySQL query?

SELECT TRIM(BOTH ',' FROM ',,,demo, ,xxxx,,,yyy,,,'); SELECT REPLACE(TRIM(TRIM(',' FROM ',,,demo, ,xxxx,,,yyy,,,')), ',,', ',');

How do I trim a comma in MySQL?

To remove all characters after the last comma in the string, you can use SUBSTRING_INDEX(). If you do not know the location of the last comma, then you need to find the last comma dynamically using LENGTH().

How do I change a dot in SQL?

To replace dot with comma on SELECT, you can use REPLACE().


1 Answers

You can use something like this:

SELECT REPLACE(fieldname, ',', '')
FROM ...

Or if type of fieldname is integer use this query

SELECT REPLACE(CONCAT(fieldname), ',', '')
FROM ...
like image 56
miltos Avatar answered Sep 23 '22 07:09

miltos