Mysql´æ´¢¹ý³Ì£¨Èý£©——´¦Àí·ÖÒ³
·ÖÒ³¹¦ÄÜÔÚÈκÎÓ¦ÓÃÖж¼±È½Ï³£¼û£¬¶ø
Mysql
µÄ´æ´¢¹ý³Ì·ÖÒ³±ØÐëͨ¹ý¶¯Ì¬
sql
À´Ö´ÐС£·ÖÒ³¶ÔÓ¦µÄ
offset
ºÍ
row_count
±ØÐëÏÈÓÃ
concat
º¯Êý±ä³É×Ö·û´®×é×°µ½
sql
ÖУ¨ÈçÓï¾ä
1
£©£¬¶ø²»ÄÜÖ±½ÓʹÓã¨ÈçÓï¾ä
2
£¬
Mysql
²»Ö§³Ö£©¡£
Mysql
·ÖÒ³¹¦ÄܵÄʵÏÖÈçÏ´úÂëËùʾ£º
Sql
code 3-1:
CREATE PROCEDURE test_proc_multi_select(IN i_pageIndex INT, IN i_pageSize INT)
BEGIN
declare stmt varchar(2000);
set @sql = concat('select * from testproc limit ',(i_pageIndex-1) * i_pageSize,' , ',i_pageSize); -- Óï¾ä1×é×°sql
prepare stmt from @sql; -- µÃµ½prepare stmt
execute stmt; -- Ö´ÐÐselect
-- ////ÒÔÏ·½Ê½±àÒë²»ÄÜͨ¹ý£¡
-- select * from testproc limit (i_pageIndex-1)*i_pageSize,i_pageSize; -- Óï¾ä2
END
ÒÔÏ´úÂëÌṩÁË´ø
where
Ìõ¼þµÄ·ÖÒ³£º
Sql
code 3-2:
CREATE PROCEDURE test_proc_param_select(IN i_name VARCHAR(100),IN i_pageIndex INT, IN i_pageSize INT)
BEGIN
declare stmt varchar(2000);
set @sql = concat('select * from testproc where name like ''%',i_name,'%'' limit ',(i_pageIndex-1) * i_pageSize,',',i_pageSize); --×¢ÒâlikeºóÁ½¸öµ¥ÒýºÅ±íʾһ¸ö¡£
prepare stmt from @sql;
execute stmt;
END;
Ïà¹ØÎĵµ£º
±¾ÎĽéÉÜÁËÊý¾Ý¿âË÷Òý£¬¼°ÆäÓÅ¡¢È±µã¡£Õë¶ÔMySQLË÷ÒýµÄÌص㡢ӦÓýøÐÐÁËÏêϸµÄÃèÊö¡£·ÖÎöÁËÈçºÎ±ÜÃâMySQLÎÞ·¨Ê¹Óã¬ÈçºÎʹÓÃEXPLAIN·ÖÎö²éѯÓï¾ä£¬ÈçºÎÓÅ»¯MySQLË÷ÒýµÄÓ¦Óᣱ¾ÎÄÕª×Ô¡¶MySQL 5ȨÍþÖ¸ÄÏ¡·(3rd)µÄ8.9½Ú¡£(2007.07.05×îºó¸üÐÂ)
Ë÷ÒýÊÇÒ»ÖÖÌØÊâµÄÎļþ(InnoDBÊý¾Ý±íÉϵÄË÷ÒýÊDZí¿Õ¼äµÄÒ»¸ö× ......
MySQL Ìí¼ÓÍâ¼ü
DROP TABLE IF EXISTS `nation`;
CREATE TABLE `nation`(
`pii_Nation` smallint(2) unsigned NOT NULL default '0',
`pii_NatinoName` varchar(40) NOT NULL default '',
PRIMARY KEY (`pii_Nation`)
)ENGINE=InnoDB DEFAULT CHARSE ......
Òª°²×° MySQL£¬¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÏÂÁÐÃüÁ
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql
// °²×°php5-mysql Êǽ«phpºÍmysqlÁ¬½ÓÆðÀ´
Ò»µ©°²×°Íê³É£¬MySQL ·þÎñÆ÷Ó¦¸Ã×Ô¶¯Æô¶¯¡£Äú¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÒÔÏÂÃüÁîÀ´¼ì²é MySQL ·þÎñÆ÷ÊÇ·ñÕýÔÚÔËÐУº ......
½ñÌì¸øÐÂÀ´µÄÔ±¹¤Á¬½ÓÊý¾Ý¿â£¬ÐÞ¸ÄÁËÒ»ÏÂmysql rootÓû§µÄÃÜÂ룬ÎÒÏÂÔصÄÊÇ´ò°üµÄredMine£¬Ä¬ÈÏÃÜÂëÊÇ¿Õ£¬ÐÞ¸ÄÃÜÂëÖ®ºóÖØÆôredmine£¬phpAdmin Á´½Ó²»ÉÏmysqlÊý¾Ý¿âÁË£¬ÎÒÒ²ÐÞ¸ÄÁËphpadminÎļþ¼ÐϵÄconfig.inc.phpµÄÃÜÂ룬»¹ÊDz»ÐУ¬Ìáʾ#1130 - Host 'localhost' is not allowed to connect to this MySQL server´íÎó£¬Ã÷ ......