Posts Tagged database

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.

Continue reading “Customizing Mysql Prompt For multiple Servers” »


, , , , , , , , , , ,

2 Comments

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 date time format in mysql , you need to specify both date and time when you specify a group by. So grouping by day is not possible in that case. So we need to use the in-build mysql function DATE(). The function accepts date time as parameter and returns only date back. So we just need to use the DATE() function where we need to group by date and all the date time values are converted to date and can be grouped by date. So here is the implementation of it.

Continue reading “Group by Date when Stored in Mysql DataBase as Date Time” »


, , , , , , ,

1 Comment

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. Continue reading “Check if a table exists in MySQL from PHP” »


, , , , , ,

No Comments