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.
SELECT TRIM(BOTH ',' FROM ',,,demo, ,xxxx,,,yyy,,,'); SELECT REPLACE(TRIM(TRIM(',' FROM ',,,demo, ,xxxx,,,yyy,,,')), ',,', ',');
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().
To replace dot with comma on SELECT, you can use REPLACE().
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 ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With