MySQL Order ByË÷ÒýÓÅ»¯
ÔÚһЩÇé¿öÏ£¬MySQL¿ÉÒÔÖ±½ÓʹÓÃË÷ÒýÀ´Âú×ãÒ»¸ö ORDER BY »ò GROUP BY ×Ó¾ä¶øÎÞÐè×ö¶îÍâµÄÅÅÐò¡£¾¡¹Ü ORDER BY ²»ÊǺÍË÷ÒýµÄ˳Ðò׼ȷƥÅ䣬Ë÷Òý»¹ÊÇ¿ÉÒÔ±»Óõ½£¬Ö»Òª²»ÓõÄË÷Òý²¿·ÖºÍËùÓеĶîÍâµÄ ORDER BY ×Ö¶ÎÔÚ WHERE ×Ó¾äÖж¼±»°üÀ¨ÁË¡£ ¡¡¡¡Ê¹ÓÃË÷ÒýµÄMySQL Order By ¡¡¡¡ÏÂÁеļ¸¸ö²éѯ¶¼»áʹÓÃË÷ÒýÀ´½â¾ö ORDER BY »ò GROUP BY ²¿·Ö£º SELECT * from t1 ORDER BY key_part1,key_part2,... ; SELECT * from t1 WHERE key_part1=constant ORDER BY key_part2; SELECT * from t1 WHERE key_part1=constant GROUP BY key_part2; SELECT * from t1 ORDER BY key_part1 DESC, key_part2 DESC; SELECT * from t1 WHERE key_part1=1 ORDER BY key_part1 DESC, key_part2 DESC; ¡¡¡¡²»Ê¹ÓÃË÷ÒýµÄMySQL Order By ¡¡¡¡ÔÚÁíһЩÇé¿öÏ£¬MySQLÎÞ·¨Ê¹ÓÃË÷ÒýÀ´Âú×ã ORDER BY£¬¾¡¹ÜËü»áʹÓÃË÷ÒýÀ´ÕÒµ½¼Ç¼À´Æ¥Åä WHERE ×Ӿ䡣ÕâЩÇé¿öÈçÏ£º ¡¡¡¡* ¶Ô²»Í¬µÄË÷Òý¼ü×ö ORDER BY £º SELECT * from t1 ORDER BY key1, key2; ¡¡¡¡* ÔÚ·ÇÁ¬ÐøµÄË÷Òý¼ü²¿·ÖÉÏ×ö ORDER BY£º SELECT * from t1 WHERE key2=constant ORDER BY key_part2; ¡¡¡¡* ͬʱʹÓÃÁË ASC ºÍ DESC£º SELECT * from t1 ORDER BY key_part1 DESC, key_part2 ASC; * ÓÃÓÚËÑË÷¼Ç¼µÄË÷Òý¼üºÍ×ö ORDER BY µÄ²»ÊÇͬһ¸ö£º SELECT * from t1 WHERE key2=constant ORDER BY key1; ¡¡¡¡* Óкܶà±íÒ»Æð×öÁ¬½Ó£¬¶øÇÒ¶ÁÈ¡µÄ¼Ç¼ÖÐÔÚ ORDER BY ÖеÄ×ֶζ¼²»È«ÊÇÀ´×ÔµÚÒ»¸ö·Ç³£ÊýµÄ±íÖУ¨Ò²¾ÍÊÇ˵£¬ÔÚ EXPLAIN ·ÖÎöµÄ½á¹ûÖеĵÚÒ»¸ö±íµÄÁ¬½ÓÀàÐͲ»ÊÇ const£©¡£ * ʹÓÃÁ˲»Í¬µÄ ORDER BY ºÍ GROUP BY ±í´ïʽ¡£ ¡¡¡¡* ±íË÷ÒýÖеļǼ²»ÊÇ°´Ðò´æ´¢¡£ÀýÈ磬HASH ºÍ HEAP ±í¾ÍÊÇÕâÑù¡£ ¡¡¡¡Í¨¹ýÖ´ÐÐ EXPLAIN SELECT ... ORDER BY£¬¾ÍÖªµÀMySQLÊÇ·ñÔÚ²éѯÖÐʹÓÃÁËË÷Òý¡£Èç¹û Extra ×ֶεÄÖµÊÇ Using filesort£¬Ôò˵Ã÷MySQLÎÞ·¨Ê¹ÓÃË÷Òý¡£ÏêÇéÇë¿´"7.2.1 EXPLAIN Syntax (Get Information About a SELECT)"¡£µ±±ØÐë¶Ô½á¹û½øÐÐÅÅÐòʱ£¬MySQL 4.1ÒÔÇ° ËüʹÓÃÁËÒÔÏ filesort Ëã·¨£º ¡¡¡¡1. ¸ù¾ÝË÷Òý¼ü¶ÁÈ¡¼Ç¼£¬»òÕßɨÃèÊý¾Ý±í¡£ÄÇЩÎÞ·¨Æ¥Åä WHERE ·Ö¾äµÄ¼Ç¼¶¼»á±»ÂÔ¹ý¡£ ¡¡¡¡2. ÔÚ»º³åÖÐÿÌõ¼Ç¼¶¼ÓÃÒ»¸ö‘¶Ô’´æ´¢ÁË2¸öÖµ£¨Ë÷Òý¼ü¼°¼Ç¼ָÕ룩¡£»º³åµÄ´óСÒÀ¾Ýϵͳ±äÁ¿ sort_buffer_size µÄÖµ¶ø¶¨¡£ ¡¡¡¡3. µ±»º³åÂýÁËʱ£¬¾ÍÔËÐÐ qsort£¨¿ìËÙÅÅÐò£©²¢½«½á¹û´æ´¢ÔÚÁÙʱÎļþÖС£½«´æ´¢µÄ¿éÖ¸Õë±£´æÆðÀ´£¨Èç¹ûËùÓ
Ïà¹ØÎĵµ£º
MySQL²éѯ±íÄÚÖظ´¼Ç¼
²éѯ¼°É¾³ýÖظ´¼Ç¼µÄ·½·¨
(Ò»)
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΠ......
Ò»¡¢¸ÅÊö
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊÇÔÚ MySQL 5.1 ÖÐÐÂÔöµÄÁíÒ»¸öÌØÉ«¹¦ÄÜ£¬¿ÉÒÔ×÷Ϊ¶¨Ê±ÈÎÎñµ÷¶ÈÆ÷£¬È¡´ú²¿·ÖÔÏÈÖ»ÄÜÓòÙ×÷ϵͳÈÎÎñµ÷¶ÈÆ÷²ÅÄÜÍê³ÉµÄ¶¨Ê±¹¦>ÄÜ¡£ÀýÈ磬Linux ÖÐµÄ crontabe Ö»Äܾ«È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î£¬¶ø MySQL µÄʼþµ÷¶ÈÆ÷Ôò¿ÉÒÔʵÏÖÿÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬ÕâÔÚһЩ¶ÔʵʱÐÔÒª>Çó½Ï¸ßµÄ»·¾³Ï¾ͷdz£ÊµÓÃÁ ......
Mysql·½Ê½£º
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class MysqlDB {
private String strClass = "com.mysql.jdbc.Driver";
private String strDriver = "jdbc:mysql://localhost: ......
½â¾öThe‘InnoDB’feature is disabled; you need MySQL built with ‘InnoDB’ to have it2009Äê12ÔÂ29ÈÕ ÐÇÆÚ¶þ ÉÏÎç 11:15MySQL
³öÏÖÈçÏÂÓï¾ä£ºThe ‘InnoDB’ feature is disabled; you need MySQL built with ‘InnoDB’ to have it working£»
ÊÇmysqlÅäÖÃÎļþ½ûµôÁËÕâ¸öÑ¡ ......
MySQL Administrator ÊÇʲôÈí¼þ£¿
MySQL Administrator ÊÇÒ»¸öרÃÅÓÃÓÚ¹ÜÀí My SQL 4.X ºÍ 5.X My SQLÊý¾Ý¿âµÄÈí¼þ£¬¿ÉÒÔʹÓÃÕâ¸öÈí¼þ±¸·ÝMy SQLÊý¾Ý¿â£¬»¹ÔMy SQLÊý¾Ý¿â¡£
×¢£ºÈç¹ûÄãµÄÊý¾Ý¿âÊÇ MS SQL 2000 Êý¾Ý¿â£¬Çë²Î¿¼ÕâÀʹÓà MS SQL 2000 ÆóÒµ¹ÜÀíÆ÷¹ÜÀí
ÏÂÔØ MySQL Administrator Èí¼þ
http://61.139.76 ......