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('ÔĶÁ,½»ÓÑ,ΧÆå,×ãÇò,»¬Ñ©',',','|') |
+---------------------------------------------+
| ÔĶÁ|½»ÓÑ|ΧÆå|×ãÇ
Ïà¹ØÎĵµ£º
ÕâÀïÊÕ¼¯¸÷ÖÖMysqlµÄ»ù´¡ÖªÊ¶,ΪÁËijЩ³¡ºÏµÄÐèÒª,»¹ÊÇÉáÆúnavicatÖ®ÀàµÄ¹¤¾ß¹Ô¹ÔÓÃÃüÁîÐаÉ
£¨×¢ÒâÓеÄÃüÁîÐèÒª·ÖºÅÓеIJ»ÐèÒª)
Ò».»ù±¾²Ù×÷
1.怬
mysql -u Óû§Ãû -pÃÜÂë Êý¾Ý¿âÃû
ÕâÀïÐè ......
µ¼³ö
select field1,field2,field3 from tablename into outfile '/home/output1.csv' fields terminated by ','optionally enclosed by ''lines terminated by '\n';
µ¼Èë
load data local infile '/home/output1.csv' into table tablename fields terminated by ','lines terminated by '\n'(field1,f ......
MySQLÊÖ²áÖп´µ½µÄ£¬¼Ç¼Ï¡£
MySQL¿ÉÒÔΪ¶à¸öÁд´½¨Ë÷Òý¡£Ò»¸öË÷Òý¿ÉÒÔ°üÀ¨15¸öÁС£¶ÔÓÚijЩÁÐÀàÐÍ£¬¿ÉÒÔË÷ÒýÁеÄǰ׺(²Î¼û7.4.3½Ú£¬“ÁÐË÷Òý”)¡£
¶àÁÐË÷Òý¿ÉÒÔÊÓΪ°üº¬Í¨¹ýÁ¬½ÓË÷ÒýÁеÄÖµ¶ø´´½¨µÄÖµµÄÅÅÐòµÄÊý×é¡£
MySQL°´ÕâÑùµÄ·½Ê½Ê¹Óöà ......
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON bankaccount.*
-> TO 'custom'@'localhost'
-> IDENTIFIED BY 'password';
mysql> GRANT SELECT,INS ......