Posts

Display row number in Mysql Select Query

…  mark of the person. So lets see how to implement this in mysql. There is no straight forward function or query parameter to do it (At …

Customizing Mysql Prompt For multiple Servers

…  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 …

Important MySQL DBA Interview Questions

…  are a few sets of interview questions expected for MySQL DBA position.These are compilation of the usual questions from various …

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). …  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 mysql client, the only way to know this is by checking the Global Variable set. …

Group by Date when Stored in Mysql DataBase as Date Time

…  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 …

Generate Date from a range in Mysql and pad the results where no date is present

…  you want to generate dates, MYSQL doesn’t have a range function, so I wrote a work around for the same. So …

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:



SELECT @row := …

Get the nth Word from a text field in mysql

…  functions available in MYSQL So here is the query for it:



 select Name, …

Check if a table exists in MySQL from PHP

…  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 mysql command show tables . Which will give me the list of tables and then …

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 …