Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Mysql ½»²æ²éѯ

CREATE TABLE `taa` (
   `year` varchar(4) DEFAULT NULL,
   `month` varchar(2) DEFAULT NULL,
   `amount` double DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf
"year","month",amount
"1991","1",1.1
"1991","2",1.2
"1991","3",1.3
"1991","4",1.4
"1992","1",2.1
"1992","2",2.2
"1992","3",2.3
"1992","4",2.4
1.select  a.year,a.m1,a.m2,b.m3,b.m4 from
(select year,
sum(if(month=1,amount,0)) as m1,
sum(if(MONTH=2,amount,0)) AS m2
from taa
group by year) a,
(SELECT year,
SUM(IF(MONTH=3,amount,0)) AS m3,
SUM(IF(MONTH=4,amount,0)) AS m4
from taa
GROUP BY YEAR) b
where a.year=b.year;
2.select year,
max((case month when 1 then amount end)) as m1,
max((CASE MONTH WHEN 2 THEN amount END)) AS m2,
max((CASE MONTH WHEN 3 THEN amount END)) AS m3,
max((CASE MONTH WHEN 4 THEN amount END)) AS m4
from taa
group by year;


Ïà¹ØÎĵµ£º

MySQL±¸·ÝµÄ¼¸ÖÖ·½Ê½µÄÌÖÂÛ£¬Öصã¹Ø×¢ÔÚÏßÈȱ¸

MySQLµÄ±¸·Ý·½Ê½£¬Ä¿Ç°ÎÒÏëµ½µÄÓÐÎåÖÖ£¬ÓпÉÄÜ»¹ÓÐ
1£¬mysqldump·½Ê½£¬¼ÓÉϾßÌå²ÎÊýÃû£¨µ¥¿â£¬¶à¿â£¬´¥·¢Æ÷£¬´æ´¢¹ý³Ì£¬±í½á¹¹£¬×Ö·û¼¯£¬–single-transaction£¬µÈµÈ£©
2£¬mysqlhotcopy Ö»Äܱ¸·ÝmyisamÊý¾Ý±í±¸·Ý£¬ËÙ¶ÈÏ൱¿ì£¬ÒòΪÊÇÎļþ¿½±´£¬¿ÉÄÜ˲¼ä±»Ëø±í£¬ÈκεÄÊý¾Ý²Ù×÷£¬±ÈÈç²åÈëºÍ¸üж¼»á¹ÒÆð¡£
3£¬LVMµ ......

MySQL Êý¾Ý¿â³£ÓÃÃüÁî

1¡¢MySQL³£ÓÃÃüÁî
create database name; ´´½¨Êý¾Ý¿â
use databasename; Ñ¡ÔñÊý¾Ý¿â
drop database name Ö±½Óɾ³ýÊý¾Ý¿â£¬²»ÌáÐÑ
show tables; ÏÔʾ±í
describe tablename; ±íµÄÏêϸÃèÊö
select ÖмÓÉÏdistinctÈ¥³ýÖظ´×Ö¶Î
mysqladmin drop databasename ɾ³ýÊý¾Ý¿âÇ°£¬ÓÐÌáʾ¡£
ÏÔʾµ±Ç°mysql°æ±¾ºÍµ±Ç°È ......

²é¿´ MySql ×Ö·û¼¯

¹Ø¼ü×Ö: mysql


MySQL ÂÒÂëµÄ¸ùÔ´ÊÇµÄ MySQL ×Ö·û¼¯ÉèÖò»µ±µÄÎÊÌ⣬±¾ÎÄ»ã×ÜÁËÓйز鿴 MySQL ×Ö·û¼¯µÄÃüÁî¡£°üÀ¨²é¿´ MySQL Êý¾Ý¿â·þÎñÆ÷×Ö·û¼¯¡¢²é¿´ MySQL Êý¾Ý¿â×Ö·û¼¯£¬ÒÔ¼°Êý¾Ý±íºÍ×ֶεÄ×Ö·û¼¯¡¢µ±Ç°°²×°µÄ MySQL ËùÖ§³ÖµÄ×Ö·û¼¯µÈ¡£
Ò»¡¢²é¿´ MySQL Êý¾Ý¿â·þÎñÆ÷ºÍÊý¾Ý¿â×Ö·û¼¯¡£
mysql> show variab ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ