Posts
Simplest way to remove trailing zeros of decimal numbers
This is a simple method I found to remove or strip trailing zeros of a decimal number. The function accepts the decimal number and return the trimmed value back. It removes all the redundant zeros in the number after the decimal point and if no number othe …
Customizing Mysql Prompt For multiple Servers
If you are using mysql regularly on multiple servers its really useful to have the promt in mysql to show something more than mysql>. It would be useful if it showed the username,hostname, current database and things like that. So how to do this. …
Generate Date from a range in Mysql and pad the results where no date is present
If you want to generate dates, MYSQL doesn’t have a range function, so I wrote a work around for the same. So how it works is I have reused a code to generate numbers from my previous post. So I added date function to that query and reduce the generated …
Generate 1 to 1000 in mysql
Sometimes its necessary to have thousand rows to join or generate new values, we need to get the thousand rows first. For this I used union of numbers 0-9. I have joined four of these to get to four digit values. So here is the code: [sql]SELECT @ro …
Web page Performance for a Blog – Part 1
I have always under the notion that page performance for big websites or websites that have a sole server and various resources like CDN and load balancers. So I wanted to know if this is true. I set out to try web page performance my blog. I just wanted t …
Check the port in which the Mysql is running on
Mysql can be configured to run other ports other than the default port (of 3306). So what will you do when you need to find the port on which a mysql server runs on. If you don’t have access to the server files and can access the server only using the mysq …
Group by Date when Stored in Mysql DataBase as Date Time
I have a table called date_count with 2 columns one is a value and another is a date time, say called date_time in mysql. Date Time in mysql is stored as dd-mm-yy hh:mm:ss. The issue comes when I need to get the number of rows per day. As its stored as dat …
Check if a table exists in MySQL from PHP
Sometimes its necessary to execute a query or execute some code if a table exists or not. So a bit of searching got me to the conclusion that mysql doesn’t have a direct query or method for it from php. So there are two methods to do it. Use the mys …
Recent Comments