ÀûÓÃMySQLµÄÒ»¸öÌØÐÔʵÏÖMySQL²éѯ½á¹ûµÄ·ÖÒ³ÏÔʾ
ÔÚmysqlÖÐÀûÓÃselectÓï¾äµÄÒ»¸öÌØÐԾͿÉÒԺܷ½±ãµØʵÏÖ²éѯ½á¹ûµÄ·ÖÒ³£¬selectÓï¾äµÄÓï·¨£º
SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [HIGH_PRIORITY]
[DISTINCT | DISTINCTROW | ALL]
select_expression,...
[INTO OUTFILE 'file_name' export_options]
[from table_references
[WHERE where_definition]
[GROUP BY col_name,...]
[HAVING where_definition]
[ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,...]
[LIMIT [offset,] rows]
[PROCEDURE procedure_name] ]
LIMIT×Ó¾ä¿ÉÒÔÓÃÀ´ÏÞÖÆÓÉSELECTÓï¾ä·µ»Ø¹ýÀ´µÄÊý¾ÝÊýÁ¿£¬ËüÓÐÒ»¸ö»òÁ½¸ö²ÎÊý£¬Èç¹û¸ø³öÁ½¸ö²ÎÊý£¬
µÚÒ»¸ö²ÎÊýÖ¸¶¨·µ»ØµÄµÚÒ»ÐÐÔÚËùÓÐÊý¾ÝÖеÄλÖ㬴Ó0¿ªÊ¼£¨×¢Òâ²»ÊÇ1£©£¬µÚ¶þ¸ö²ÎÊýÖ¸¶¨×î¶à·µ»ØÐÐ
Êý¡£ÀýÈ磺
select * from table LIMIT 5,10; #·µ»ØµÚ6-15ÐÐÊý¾Ý
select * from table LIMIT 5; #·µ»ØÇ°5ÐÐ
select * from table LIMIT 0,5; #·µ»ØÇ°5ÐÐ
Ïà¹ØÎĵµ£º
Ò»¡¢¸ÅÊö
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊÇÔÚ MySQL 5.1 ÖÐÐÂÔöµÄÁíÒ»¸öÌØÉ«¹¦ÄÜ£¬¿ÉÒÔ×÷Ϊ¶¨Ê±ÈÎÎñµ÷¶ÈÆ÷£¬È¡´ú²¿·ÖÔÏÈÖ»ÄÜÓòÙ×÷ϵͳÈÎÎñµ÷¶ÈÆ÷²ÅÄÜÍê³ÉµÄ¶¨Ê±¹¦>ÄÜ¡£ÀýÈ磬Linux ÖÐµÄ crontabe Ö»Äܾ«È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î£¬¶ø MySQL µÄʼþµ÷¶ÈÆ÷Ôò¿ÉÒÔʵÏÖÿÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬ÕâÔÚһЩ¶ÔʵʱÐÔÒª>Çó½Ï¸ßµÄ»·¾³Ï¾ͷdz£ÊµÓÃÁ ......
Óöµ½Ò»¸öÎÊÌâÊÇÔÚMySQLÃüÁîÐвåÈëÖÐÎÄÊý¾Ý»òÕß²éѯÖÐÎÄÊý¾Ýʱ³öÏÖÂÒÂ룬»òÕßÏÔʾ²»¶Ô¡£
ÔÚÃüÁîÐÐÊäÈë:show variables like ‘character_set_%’;
²é¿´µ±Ç°ÅäÖõıàÂ룻
ÔÚÃüÁîÐÐÊäÈë :set names utf8;
ÔòµÈͬÓÚ
set character_set_client=utf8;
set character_set_results ......
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: ......
½ñÌìÎÒÃÇ¿´¿´¹ØÓÚMySQLÂýÈÕÖ¾µÄÔĶÁ¡£
ÎÒÃÇÖªµÀ£¬Èç¹ûÎÒÃǵÄÓï¾ä²»¹»ÓÅ»¯£¬ÄÇôÊ×ÏÈMySQLµÄÂýÈÕÖ¾ÊǽøÒ»²½ÓÅ»¯µÄÀëÏßÖ¤¾Ý£¬ËäÈ»ÀïÃæÓкÃ
¶à“αÂýÓï¾ä”£¡
ÏȲ»ËµÔõôÓÅ»¯£¬Èç¹ûÄãµÄÈÕÖ¾ÓÐÒ»ÌõÓï¾ä¶ÄסÁË£¬ÄÇô»áÓв»¼ÆÆäÊýµÄÂýÓï¾äÌî³äµ½MySQLµÄÂúÈÕÖ¾ÀïÃæ¡£ÄÇôÊ×ÏÈÌáÁ¶³öÕâЩÓï
¾ä¾Í·Ç³£Í·ÌÛ¡£
½ñÌìÖ÷Òª½ ......
ÔÚһЩÇé¿öÏ£¬MySQL¿ÉÒÔÖ±½ÓʹÓÃË÷ÒýÀ´Âú×ãÒ»¸ö ORDER BY »ò GROUP BY ×Ó¾ä¶øÎÞÐè×ö¶îÍâµÄÅÅÐò¡£¾¡¹Ü ORDER BY ²»ÊǺÍË÷ÒýµÄ˳Ðò׼ȷƥÅ䣬Ë÷Òý»¹ÊÇ¿ÉÒÔ±»Óõ½£¬Ö»Òª²»ÓõÄË÷Òý²¿·ÖºÍËùÓеĶîÍâµÄ ORDER BY ×Ö¶ÎÔÚ WHERE ×Ó¾äÖж¼±»°üÀ¨ÁË¡£ ¡¡¡¡Ê¹ÓÃË÷ÒýµÄMySQL Order By ¡¡¡¡ÏÂÁеļ¸¸ö²éѯ¶¼»áʹÓÃË÷ÒýÀ´½â¾ö ORDER BY ......