mysql Ò»µÀСÌâ
±íÃûΪtableµÄ±íÄÚÈÝÈçÏÂ
Year month value
2009 1 1.1
2009 2 1.2
2009 3 1.3
2009 4 1.4
2010 1 2.1
2010 2 2.2
2010 3 2.3
2010 4 2.4
ÒªÇó²éѯ½á¹ûΪ
year m1 m2 m3 m4
2009 1.1 1.2 1.3 1.4
2010 2.1 2.2 2.3 2.4
mysql> select year,sum(case when month=1 then value end) as 'm1',sum(case when m
onth=2 then value end) as 'm2',sum(case when month=3 then value end)as 'm3' from
table2 group by year;
Ïà¹ØÎĵµ£º
ĿǰÓв»ÉÙAMP£¨Apache\MySQL\PHP£©µÄ¼¯³ÉÈí¼þ£¬¿ÉÒÔÈÃÎÒÃÇÒ»´Î°²×°²¢ÉèÖúá£Õâ¶ÔÓÚ²»ÊìϤAMPµÄÓû§À´Ëµ£¬ºÃ´¦¶à¶à¡£
Ò»¡¢Ê¹ÓÃAMP¼¯³ÉÈí¼þµÄÓŵ㣺
1¡¢¿É±ÜÃâÓÉÓÚȱ·¦AMPµÄ֪ʶ£¬¶øÎÞ·¨ÕýÈ·ÉèÖû·¾³£»
2¡¢¿É¿ìËÙ°²×°²¢ÉèÖúÃAMP»·¾³£¬ÈÃÎÒÃÇÖ±½Ó¿ªÊ¼ÕæÕý¸ÐÐËȤµÄÈí¼þ£¬Èçxoops£»
3¡¢¿É·½±ãµÄ´î½¨²âÊÔ»·¾³£¬¶ÔÓÚ² ......
×÷ÕߣºÒ¶½ðÈÙ£¨Email: imysql#gmail.com£©£¬À´Ô´£ºhttp://iMySQL.cn£¬×ªÔØÇë×¢Ã÷×÷Õߺͳö´¦£¬²¢ÇÒ²»ÄÜÓÃÓÚÉÌÒµÓÃ;£¬Î¥Õ߱ؾ¿¡£
MySQLÌṩÁËÊý¾Ý¿âµÄͬ²½¹¦ÄÜ£¬Õâ¶ÔÎÒÃÇʵÏÖÊý¾Ý¿âµÄÈßÔÖ¡¢±¸·Ý¡¢»Ö¸´¡¢¸ºÔؾùºâµÈ¶¼ÊÇÓм«´ó°ïÖúµÄ¡£±¾ÎÄÃèÊöÁ˳£¼ûµÄͬ²½ÉèÖ÷½·¨¡£
Ò»¡¢×¼±¸·þÎñÆ÷
ÓÉÓÚMySQL²»Í¬°æ±¾Ö®¼äµÄ(¶þ½øÖÆÈÕÖ¾)b ......
MySQLÊý¾Ý¿âµÄ¼òµ¥²Ù×÷
Ò».´´½¨Êý¾Ý¿â ͨ¹ýshow databases;ÃüÁîÏÔʾËùÓÐÒÑ´´½¨µÄÊý¾Ý¿âµÄÃû³Æ¡£
ͨ¹ýcreate database XXX;´´½¨Êý¾Ý¿âÃûΪXXXµÄÊý¾Ý¿â¡£ ÀýÈ磺mysql>create database test; ¶þ.´´½¨±íµ¥ ͨ¹ýcreate table XXX();´´½¨ ÀýÈç: È»ºó¿ÉÒÔͨ¹ýdescÃüÁî²é¿´±íµ¥: ÀýÈç: Èý ......
MySQL MyIsam ´æ´¢ÒýÇæÔÚ´´½¨Ë÷ÒýµÄʱºò£¬Ë÷Òý¼ü³¤¶ÈÊÇÓÐÒ»¸ö½ÏΪÑϸñµÄ³¤¶ÈÏÞÖÆµÄ£¬ËùÓÐË÷Òý¼ü×î´ó³¤¶È×ܺͲ»Äܳ¬¹ý1000£¬¶øÇÒ²»ÊÇʵ¼ÊÊý¾Ý³¤¶ÈµÄ×ܺͣ¬¶øÊÇË÷Òý¼ü×ֶζ¨Ò峤¶ÈµÄ×ܺ͡£ÏÂÃæ×ö¸ö¼òµ¥µÄ²âÊÔ£¬¼Ç¼һÏ¡£
root@sky:~# mysql -u sky -p -h127.0.0.1
Enter password:
Welcome to the MySQL monitor. Command ......