mysqlÖÐÖÐ×Ö·û´®½ØÈ¡º¯Êý
MySQL ×Ö·û´®½ØÈ¡º¯Êý£ºleft(), right(), substring(), substring_index()¡£»¹ÓÐ mid(), substr()¡£ÆäÖУ¬mid(), substr() µÈ¼ÛÓÚ substring() º¯Êý£¬substring() µÄ¹¦Äܷdz£Ç¿´óºÍÁé»î¡£
1. ×Ö·û´®½ØÈ¡£ºleft(str, length)
mysql> select left('sqlstudy.com', 3);+-------------------------+| left('sqlstudy.com', 3) |+-------------------------+| sql |+-------------------------+2. ×Ö·û´®½ØÈ¡£ºright(str, length)
mysql> select right('sqlstudy.com', 3);+--------------------------+| right('sqlstudy.com', 3) |+--------------------------+| com |+--------------------------+3. ×Ö·û´®½ØÈ¡£ºsubstring(str, pos); substring(str, pos, len)
3.1 ´Ó×Ö·û´®µÄµÚ 4 ¸ö×Ö·ûλÖÿªÊ¼È¡£¬Ö±µ½½áÊø¡£
mysql> select substring('sqlstudy.com', 4);+------------------------------+| substring('sqlstudy.com', 4) |+------------------------------+| study.com |+------------------------------+3.2 ´Ó×Ö·û´®µÄµÚ 4 ¸ö×Ö·ûλÖÿªÊ¼È¡£¬Ö»È¡ 2 ¸ö×Ö·û¡£
mysql> select substring('sqlstudy.com', 4, 2);+---------------------------------+| substring('sqlstudy.com', 4, 2) |+---------------------------------+| st |+---------------------------------+3.3 ´Ó×Ö·û´®µÄµÚ 4 ¸ö×Ö·ûλÖ㨵¹Êý£©¿ªÊ¼È¡£¬Ö±µ½½áÊø¡£
mysql> select substring('sqlstudy.com', -4);+-------------------------------+| substring('sqlstudy.com', -4) |+-------------------------------+| .com |+-------------------------------+3.4 ´Ó×Ö·û´®µÄµÚ 4 ¸ö×Ö·ûλÖ㨵¹Êý£©¿ªÊ¼È¡£¬Ö»È¡ 2 ¸ö×Ö·û¡£
mysql> select substring('sqlstudy.com', -4, 2);+----------------------------------+| substring('sqlstudy.com', -4, 2) |+----------------------------------+| .c |+----------------------------------+ÎÒÃÇ×¢Òâµ½ÔÚº¯Êý substring(str,pos, len)ÖУ¬ pos ¿ÉÒÔÊǸºÖµ£¬µ« len ²»ÄÜÈ¡¸ºÖµ¡£
4. ×Ö·û´®½ØÈ¡£ºsubstring_index(str,delim,count)
4.1 ½ØÈ¡µÚ¶þ¸ö '.' ֮ǰµÄËùÓÐ×Ö·û¡£
mysql> select substring_index('www.sqlstudy.com.cn', '.', 2);+------------------------------------------------+| substring_index('www.sqlstudy.com.cn', '.', 2) |+------------------------------------------------+| www.sqlstudy |+------------------
Ïà¹ØÎĵµ£º
¡¡Ò»Ö±À§ÈÅÎÒ¿ì°ëÄêµÄÎÊÌâÖÕÓڵõ½½â¾ö, ·þÎñÆ÷µÄmysqlÀÏÊÇÔËÐÐÒ»¶Îʱ¼ä,×Ô¶¯Í£Ö¹ÁË,±ØÐëÊÖ¶¯Æô¶¯. !
¡¡¡¡ÎÒÕÒÆ«ÍøÉÏËùÓеķ½·¨,µ«Ã»ÓÐÒ»¸öÄܽâ¾ö,ʲôÐÞ¸ÄÅäÖÃÎļþ°¡.¶¨Ê±Æô¶¯.¶¼Ã»Ð§¹û. ¸ù¾Ýר¼Ò¹Û²ì£¬ÕâÑùµÄÀíÂÛºÍÏÖÏó¶¼ÊÇÖµµÃ¸÷λվ³¤Éî˼µÄ£¬ËùÒÔÏ£Íû´ó¼Ò¶à×öÑо¿Ñ§Ï°£¬ÕùÈ¡×ܽá³ö¸ü¶à¸üºÃµÄ¾Ñé!
¡¡¡¡Õâ¸ö·½·¨ÊÇÎÒ ......
·½·¨Ò»£º
ʹÓÃMySQLÍƳöµÄMySQL Connector/Net×é¼þ£¬ ¸Ã×é¼þÊÇMySQLΪADO.NET·ÃÎÊMySQLÊý¾Ý¿âÉè¼ÆµÄ.NETרÓ÷ÃÎÊ×é¼þ¡£Íê³É¸Ã×é¼þºó£¬ÐèÒªÔÚÏîÄ¿ÖÐÒýÓÃÕâ¸ö×é¼þ£¬Ò²¿ÉÒÔÖ±½ÓÔÚÅäÖÃÎļþµÄ<assemblies>½ÚµãÄÚÌí¼ÓÏÂÃæµÄ½Úµã£º
<add assembly="MySql.Data, Version=5.1.5.0, Culture=neutral, PublicKeyToken=C5687 ......
Ô¶³ÌµÇ¼ -h IPµØÖ·
ctrl + d Í˳ö »ò \q »ò quit
select version(); µ±Ç°°æ±¾
current_dateµ±Ç°ÈÕÆÚ »òcurdate() »ò current_date()
SELECT name, birth, curdate(),(year(curdate())-year(birth)) - (right(curdate(),5)<right(birth,5)) as age from ±í ORDER BY name;
year ÌáÈ¡Ä겿·Ö right(curdate(),5)ÌáÈ¡Ó ......
.Á¬½Ómysql mysql -uroot -padmin -hlocalhost
.Á¬½ÓmysqladminÃüÁîÐпͻ§¶Ë³ÌÐò mysqladmin -uroot -padmin -hlocalhost
.Æô¶¯mysql mysqld
.¹Ø±Õ mysqladmin -uroot -padmin -hlocalhost shutdown
.ÐÞ¸ÄÃÜÂë
set password for 'root'@'localhost' = password('admin')
update ......
Ê×ÏÈ£ºÈ·¶¨Êý¾Ý¿âµÄ±àÂëΪutf8£¬Õý³£´¢´æÖÐÎÄ£¨ÓÃMySQL-Front²é¿´ÖÐÎÄÊÇ·ñÕý³££©
È»ºó£ºServices²éѯMySQLʱʹÓÃ"SET NAMES 'utf8'"£¬ÇÒͨ¹ý"amfphp/browser"ÔËÐп´¿´ÊÇ·ñÖÐÎÄ£¬Èç¹ûÂÒÂëÔòÐÞ¸Ägateway.phpÎļþ£¬È¥µô $gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");
×îºó£ºÔËÐÐFlex³ÌÐòÏÔ ......