Archive for January, 2009

Yesman

One of the best comedy movies in 2008.
Unfortunately real comedy movie is infrequent thing now. So it is quite easy to be “one of the best”.
Anyway I enjoyed watching Yesman (except couple moments 😉 ).

Farmer Cheese

Thanks to Whole Foods I have found farmer cheese recently. Russian caption is not the only difference with cottage cheese. For instance it is unsalted! 🙂

Farmer Cheese

MySQL: Group Concatination

Like row maximum and minimum there is another interesting function GROUP_CONCAT which returns values inside group as separated string. For example:

SELECT UserType, GROUP_CONCAT(ID) FROM `User` GROUP BY UserType;

will return:
1 | 1,2,3,4,5
2 | 6,7,8,9,10

Also it is possible to set custom separator (comma by default), sort order and eliminate repeated values by using DISTINCT:

SELECT
  UserType,
  GROUP_CONCAT(DISTINCT County ORDER BY Country SEPARATOR '; ')
FROM `User`
GROUP BY UserType;

But draw attention that GROUP_CONCAT has length limit 1024 symbols. It is possible to change that limit by updating global variable group_concat_max_len.

Freaky Friday – Take Me Away

MySQL: select multiple fields into variables

Just reminder that MySQL statement for selecting more than one field into variables should look like below:

SELECT ID, `Name` INTO UserID, UserName FROM `User` WHERE ID = 100;

I.e. single INTO per SELECT statement instead of own INTO for each field.