Friday, February 22, 2013

Show fixed text in div and append ... using css

white-space: nowrap;
width: 100%;
 overflow: hidden;
 text-overflow: ellipsis;


The ellipsis value causes three periods to be appended to the text.

Wednesday, February 13, 2013

Enable slow query log in Mysql


set global slow_query_log = 'ON';
 show variables like '%slow%';
set global log_queries_not_using_indexes = 'ON'
set global slow_query_log_file ='/var/log/mysql/slow-query.log';
set global long_query_time = '20';  

Monday, February 4, 2013

Mysql In clause V/S Find_in_set

 In Clause in Mysql

In clause is used to pass multiple values for a column in where clause.We can also pass subquery to it .But in mysql there is one strange thing that if you pass a subquery in In clause.it may return unusual results.But there is a reason for this.

SELECT name FROM orders,company WHERE orderID = 1 AND companyID IN (select id from companyids)

the subquery here in In clause returns comma seperated value and mysql picks up only first value till comma.so you are expected to get unwanted results.

The solution to this problem is a function in mysql

FIND_IN_SET(,).This function returns 

  Returns 0 if str is not in strlist or if strlist is the empty string.
 Returns NULL if either argument is NULL. 
This function does not work properly if the first argument contains a comma (“,”)
 character. 
Returns a value in the range of 1 to N if the string str is in the string list

SELECT name FROM orders,company WHERE orderID = 1 
AND Find_In_set(companyID ,select id from companyids)