MySQL COUNT SUM
select
count(*) as mcount ,
left(create_time,10) as ptime ,
count(if(receive_msg is null,id,null)) as nullcount ,
count(if(receive_msg = '1',receive_msg,null)) as apfcount ,
count(if(receive_msg = '2',receive_msg,null)) as dttcount ,
count(if(receive_msg = '3',receive_msg,null)) as dicount
from
t_votes
where
left(create_time,7)>='$pearly'
and
left(create_time,7)<='$plate'
group by
ptime ;
COUNT(*)´øÉÏֵΪNULLµÄ
COUNT(table_name)²»´øֵΪNULLµÄ
¼ÆÊý²»ÇóºÍ,¿ÉÓÃÆäËû×Ö¶ÎÌæ´ú
select
count(*) as mcount ,
left(create_time,10) as ptime ,
SUM(if(receive_msg is null,id,0)) as nullcount ,
SUM(if(receive_msg = '1',receive_msg,0)) as apfcount ,
SUM(if(receive_msg = '2',receive_msg,0)) as dttcount ,
SUM(if(receive_msg = '3',receive_msg,0)) as dicount
from
t_votes
where
left(create_time,7)>='$pearly'
and
left(create_time,7)<='$plate'
group by
ptime ;
SUMÇóºÍ,×îºóÒ»¸ö²ÎÊý¸ÄΪ0.¾ßÌåÔÒò²»Ã÷
Ïà¹ØÎĵµ£º
1.ÔÚORACLEÖÐÓÃselect * from all_usersÏÔʾËùÓеÄÓû§£¬¶øÔÚMYSQLÖÐÏÔʾËùÓÐÊý¾Ý¿âµÄÃüÁîÊÇshow
databases¡£¶ÔÓÚÎÒµÄÀí½â£¬ORACLEÏîÄ¿À´ËµÒ»¸öÏîÄ¿¾ÍÓ¦¸ÃÓÐÒ»¸öÓû§ºÍÆä¶ÔÓ¦µÄ±í¿Õ¼ä£¬¶øMYSQLÏîÄ¿ÖÐÒ²Ó¦¸ÃÓиöÓû§ºÍÒ»¸ö¿â¡£ÔÚ
ORACLE(db2Ò²Ò»Ñù)Öбí¿Õ¼äÊÇÎļþϵͳÖеÄÎïÀíÈÝÆ÷µÄÂß¼±íʾ£¬ÊÓͼ¡¢´¥·¢Æ÷ºÍ´æ´¢¹ý³ÌÒ²¿É ......
mysql> desc aa;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | &n ......
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test &n ......
1.MemoryÒýÇæ,ÌṩÄÚ´æ±í
MySql Memory´æ´¢ÒýÇ棨ÀÏ°æ±¾Ò²½Ð×öheap´æ´¢ÒýÇ棩£¬¹ËÃû˼ÒåÊÇÔÚÄÚ´æÖд洢ËùÓеÄÊý¾Ý£¬Ëü¾ßÓÐÒÔÏÂÁ½¸öÃ÷ÏÔÌØÕ÷£º
¢ÙÄÚ´æÖд洢Êý¾Ý£¬·Ç³£¸ßËÙ;
¢Úmysql¹Ø±ÕºóËùÓÐÊý¾ÝÏûʧ£¬mysqlÆô¶¯Ê±»á´´ ......
±¸·ÝÊý¾Ý¿âÃüÁî:
mysqldump -u root --password=root --database helloworld
>helloworld_backup.sql
ÆäËûÓ÷¨:
1.µ¼³öÕû¸öÊý¾Ý¿â
mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû > µ¼³öµÄÎļþÃû
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2.µ¼³öÒ»¸ö±í
mysqldump -u Óû§Ãû -p Êý¾Ý¿âà ......