Showing posts with label Mysql. Show all posts
Showing posts with label Mysql. Show all posts

Thursday, 26 June 2014

Mysql query to list the Process

Below query will list the process currently accessing the server database, this will be useful in bug tracking.
show processlist();

Monday, 3 March 2014

MySQL query get first and last day of month

# For current month
SELECT DATE_FORMAT(CURDATE(), '%Y-%m-01') AS `First Day Of Current Month`;

SELECT LAST_DAY(CURDATE()) AS `Last Day Of Current Month`;


# For previous month
SELECT DATE_FORMAT(CURDATE() - INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Previous Month`;

SELECT LAST_DAY(CURDATE() - INTERVAL 1 MONTH) AS `Last Day Of Previous Month`;

# For next month
SELECT DATE_FORMAT(CURDATE() + INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Next Month`;

SELECT LAST_DAY(CURDATE() + INTERVAL 1 MONTH) AS `Last Day Of Next Month`; 

Thursday, 6 February 2014

Mysql query how to use if condition?

inside mysql query add this

  SELECT  IF( viewers > 100 , 1, 0) AS hotproduct FROM mytable
the condition is like this


IF ( condition here , true , false )