MYSQL ¶à¹Ø¼ü×ÖÏà¹ØÎÄÕ²éѯ·½·¨
È¡µÃÎÄÕ¹ؼü×ÖΪkeywords
±ínewsµÄ¹Ø¼ü×Ö×Ö¶ÎΪkeyword
keywords=keywords.replace(',','|');
String sql="SELECT * from news WHERE keyword REGEXP '"+keywords+"' ORDER BY id ";
ÓÉÓÚijЩÔÒò£¬ÓÐʱºòÎÒÃÇûÓа´ÕÕ·¶Ê½µÄÉè¼Æ×¼Ôò¶ø°ÑһЩÊôÐԷŵ½Í¬Ò»¸ö×Ö·û´®×Ö¶ÎÖС£±ÈÈç¸öÈËÐËȤ£¬ÓÐʱºòÎÒÃÇÉè¼Æ±íΪ
create table members (uid int primary key,uname varchar(20),hobby varchar(100));
±íÖÐÄÚÈÝÈçÏÂ
mysql> select * from members;
+-----+-------+---------------------------------+
| uid | uname | hobby |
+-----+-------+---------------------------------+
| 1 | AAAA | ÒôÀÖ,µçÓ°,ÍøÂç,ÀºÇò,ÔĶÁ,ƹÅÒÇò |
| 2 | BBBB | ÒôÀÖ,ÔĶÁ,ƹÅÒÇò,·¢´ô,ΧÆå,²Îìø |
| 3 | CCCC | ½»ÓÑ,ƹÅÒÇò |
| 4 | DDDD | ̨Çò,ÍøÂç,¿´Êé,ÂÃÓÎ |
| 5 | EEEE | ÒôÀÖ,·¢´ô,ÏÂΧÆå,²Îìø |
+-----+-------+---------------------------------+
4 rows in set (0.00 sec)
Èç¹ûÎÒÃÇÏÖÔÚÏë²éÕÒÒ»¸öÓëij¸öÓû§X (ÔĶÁ,½»ÓÑ,ΧÆå,×ãÇò,»¬Ñ©)ÓÐ×ÅÏàͬ°®ºÃµÄ»áÔ±¼Ç¼ Èç¹ûÀ´²Ù×÷ÄØ£¿
ÔÚÆäËüÊý¾Ý¿âÖУ¬ÎÒÃÇÄÜֻͨ¹ý³ÌÐòÀ´»òÕß´æ´¢¹ý³ÌÀ´·Ö½âÕâ¸ö "ÔĶÁ,½»ÓÑ,ΧÆå,×ãÇò,»¬Ñ©" ×Ö·û´®Îªµ¥¶ÀµÄ°®ºÃÏîÄ¿£¬È»ºóÒ»¸öÒ»¸ö½øÐÐ like '%xxxx%' À´²éѯ¡£ µ«ÔÚMySQLÖÐÎÒÃÇ¿ÉÒÔÖ±½ÓÀûÓÃÕâ¸öregexpÕý¹æ±í´ïʽ À´¹¹ÔìSQLÓï¾äÀ´ÊµÏÖ¡£
Ê×ÏÈÎÒÃÇ°Ñ 'ÔĶÁ,½»ÓÑ,ΧÆå,×ãÇò,»¬Ñ©' ת»»³ÉΪÕýÔòʽ Ϊ 'ÔĶÁ|½»ÓÑ|ΧÆå|×ãÇò|»¬Ñ©' , | ÔÚÕýÔò±í´ïʽÖÐΪ '»ò' µÄÒâ˼
mysql> select replace('ÔĶÁ,½»ÓÑ,ΧÆå,×ãÇò,»¬Ñ©',',','|');
+---------------------------------------------+
| replace('ÔĶÁ,½»ÓÑ,ΧÆå,×ãÇò,»¬Ñ©',',','|') |
+---------------------------------------------+
| ÔĶÁ|½»ÓÑ|ΧÆå|×ãÇ
Ïà¹ØÎĵµ£º
php£«mysqlÔúʵ¸öÈË»ù±¾¹¦
Ò». 10¾ä»°
1.²»ÒªÒÀÀµregister_global=ONµÄ»·¾³£¬´ÓÄã¸Õ¶®µÃÅäÖÃphpÔËÐл·¾³ÉõÖÁÉв»Ã÷°×register_globalµÄON/OFF»á¶Ô×Ô¼ºÓÐʲôӰÏìµÄÄÇÌìÆ𣬾ÍÓ¦¸ÃÓ¸ҵذÑËüÉèΪOFF.
2.д³ÌÐòÇ°¿´¿´ÔõôÓÃerror_reporting.
3.²»¶®¾ÍÎʱ¾Éíû´í£¬µ«ÄãÐèÒªÔÚÄÇ֮ǰ²é²éÊֲᡣ
4.µ±È»£¬ÄãÐèÒª¶®µÃʹÓÃÊÖ ......
Îļþphp.ini·ÅÈëwindowsÏ£¬½«ÏÂÃæÄÚÈÝ¿½±´µ½¼Çʱ¾ÃüÃûΪphp.ini·ÅÈëc:/windowsÏÂ,ÖØÆôApache server£º
[PHP]
;;;;;;;;;;;
; WARNING ;
;;;;;;;;;;;
; This is the default settings file for new PHP installations.
; By default, PHP installs itself with a configuration suitable for
; development purposes ......
ʹÓÃÁÙʱ±íµÄºÃ´¦£º
ʹÓÃÁÙʱ±í´æ·ÅÖмä½á¹û,¼ÓËÙ²éѯ£¬»ò´æ·ÅÁÙʱ½á¹û.
(1)
´´½¨ÁÙʱ±íºÜÈÝÒ×£¬¸øÕý³£µÄCREATE TABLEÓï¾ä¼ÓÉÏTEMPORARY¹Ø¼ü×Ö£º
CREATE TEMPORARY TABLE tmp_table (
name VARCHAR(10) NOT NULL,
value INTEGER NOT NULL
)
(2)
ÁÙʱ±í½«ÔÚÄãÁ¬½ÓMySQLÆÚ¼ä´æÔÚ¡£µ±Äã¶Ï¿ªÊ±£¬MySQL ......
µ±ÄãÔËÐÐmysql commond line clientºó£¬»á¿´µ½Ìáʾ·û
ÊäÈëÃÜÂëºó½øÈëÈçÏÂÒ³Ãæ
ÕâÑùÄã¾Í¿ÉÒÔÔÚÕâ¸öDOS¿òÀïÊäÈëSQLÓï¾ä£¬Ö´ÐÐÁË¡£
1 ´´½¨Êý¾Ý¿âÃüÁî
ÔÚ´´½¨Êý¾Ý¿â֮ǰ¿ÉÒÔÊÇÓÃÃüÁî
show databases;
²é¿´ÓÐÄÇЩÊý¾Ý¿â£¬ÈçÏÂͼ
³õѧÕßÔÚÊäÈëÕâ¸öÃüÁîµÄʱºò»á¾³£Íü¼ÇDATABASESµÄ×îºóÒ»¸öS£¬¿ÉÒÔÏëÏñÔÚÊý¾Ý¿âÈí¼þÖв»Ö¹ ......
1¡¢°²×°Ä¿Â¼:
½«my.iniÖÐ:
datadirµÄÖµ¸ü¸ÄΪ£º"sql/data/"
basedirµÄÖµ¸ü¸ÄΪ£º"sql"
2¡¢½øÈësql/data/"£¬É¾³ýÎļþ¼ÐÍâµÄËùÓÐÎļþ¡£
net start mysql»Ø³µ……
×¢ÒâбÏß/
ÐÞ¸Äpswd
·½·¨1£ºmysqladmin -u root -p "old password" "new password" (´ËÃüÁîÎÞ·¨°ÑÃØÃÜÇå¿Õ)
·½·¨2£º ......