Archive

Archive for the ‘MySQL’ Category

MySql count width if statement grouped

November 21st, 2009 wiley No comments

Table name – firms

Firm Sex
firm1 man
firm2 man
firm2 woman
SELECT Firm, SUM(IF(sex='man',1,0)) AS Man, SUM(IF(sex='woman',1,0)) AS Woman FROM firms GROUP BY Firm;
Firm Man Woman
firm1 1 0
firm2 1 1

Unique visitors to post: 8

Categories: MySQL Tags: , , ,

MySql integer numeric types

November 14th, 2009 wiley No comments

The following table shows the required storage and range for each of the integer types.

Type Bytes Minimum Value Maximum Value
(Signed/Unsigned) (Signed/Unsigned)
TINYINT 1 -128 127
0 255
SMALLINT 2 -32768 32767
0 65535
MEDIUMINT 3 -8388608 8388607
0 16777215
INT 4 -2147483648 2147483647
0 4294967295
BIGINT 8 -9223372036854775808 9223372036854775807
0 18446744073709551615

Unique visitors to post: 0

Categories: MySQL Tags: ,

MySQL LIMIT Clause

June 19th, 2009 wiley No comments

The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants.

With one argument:

SELECT * FROM tbl LIMIT 10;     # Retrieve first 10 rows

With one argument, the value specifies the number of rows to return from the beginning of the result set.

With two arguments:

SELECT * FROM tbl LIMIT 2,20;  # Retrieve rows from 3 to 22

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1).


Unique visitors to post: 11

Categories: MySQL Tags: ,

MySQL processing data in UTF8

May 27th, 2009 wiley No comments

Record instructions in the MySQL my.ini file for processing data in text format UTF8

[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
character-set-server=utf8
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'
[client]
default-character-set=utf8

Unique visitors to post: 1

Categories: MySQL Tags: ,
Google Analytics integration offered by Wordpress Google Analytics Plugin