: MySQL |


10

2011

6 MySQL


mysql_logo



1. ?

SELECT DATE_FORMAT(FROM_DAYS(TO_DAYS(now()) - TO_DAYS(@dateofbirth)), '%Y') + 0;

2. г

UNIX_TIMESTAMP( dt2 ) - UNIX_TIMESTAMP( dt1 )

3. , N
SELECT id FROM tbl GROUP BY id HAVING COUNT(*) = N;

4.

SELECT COUNT(*) FROM calendar WHERE d BETWEEN Start AND Stop AND DAYOFWEEK(d) NOT IN(1,7) AND holiday=0;

5.

SELECT k.column_name FROM information_schema.table_constraints t JOIN information_schema.key_column_usage k USING (constraint_name,table_schema,table_name) WHERE t.constraint_type='PRIMARY KEY' AND t.table_schema='db' AND t.table_name='tbl' 

6. ?

SELECT table_schema AS 'Db Name', Round( Sum( data_length + index_length ) / 1024 / 1024, 3 ) AS 'Db Size (MB', Round( Sum( data_free ) / 1024 / 1024, 3 ) AS 'Free Space (MB)' FROM information_schema.tables GROUP BY table_schema


: http://www.codeforest.net


: 841    : 0    :



21

2010

в


(*) (content) , id .

: 718    : 0    :