Format Query Result By Count() With Comma Using Format() In MySQL Database
I played around with MySQL count() statement. I found it annoying that the count()
will simply return whole numbers. Example: the total record of a table is 32,272.
In MySQL SQL, this will simply return 32272. Below are two sql scripts. The first
one returns whole number,while the second query returns comma separated number.
ENJOY!!!!
will simply return whole numbers. Example: the total record of a table is 32,272.
In MySQL SQL, this will simply return 32272. Below are two sql scripts. The first
one returns whole number,while the second query returns comma separated number.
ENJOY!!!!
select count(*) as num_records_notformatted from mytable where name like '%j%'; Solution: select format(count(id),0) as num_records_formatted from mytable where name like '%j%';
Comments
Post a Comment