Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÈçºÎ°ÑÕâ¸öMS SQLµÄÓï¾ä»»³ÉµÈ¼ÛµÄMySQLÓï¾ä£¿

Óï¾äÈçÏ£¬ÆäÖÐ×Ö¶ÎÃû´æ´¢µÄÊÇÍøÖ·£¬Õû¸ö´úÂëµÄ¹¦ÄܾÍÊÇͳ¼ÆÏàͬÍøÕ¾µÄ´ÎÊý£¬
±ÈÈç˵ÓÐÁ½Ìõ¼Ç¼,Ò»¸öÊÇhttp://www.baidu.com/  ÁíÒ»¸öÊÇhttp://www.baidu.com/a/b/c/d/
Õâ¶Î´úÂë¾Í»á°´ÕÕµãºÅ"."µÄλÖðÑ"baidu"È¡³öÀ´£¬ÄÇôbaiduµÄ·ÃÎÊ´ÎÊýÊÇ2£¬¾ÍÊÇÕâô¸öЧ¹û
ÏÖÔÚµÄÎÊÌâ¾ÍÊÇMySQLûÓÐÌṩCHARINDEXº¯Êý£¬ÎÒËÑÁËһϣ¬MySQLÀïÓиöinstrº¯Êý£¬µ«ÊÇÕâ¸öº¯ÊýÖ»ÄÜÓÐÁ½¸ö²ÎÊý£¬
µ«ÊÇ×¢ÒâÕâ¸ö´úÂëÖÐÓм¸¸öCHARINDEXÀïÊÇÈý¸ö²ÎÊý£¬Õâ¾ÍÊÇ×î´óµÄÎÊÌâ¡£

SQL code:


SELECT top 6
COUNT
(
SUBSTRING
(
×Ö¶ÎÃû,
CHARINDEX('.',×Ö¶ÎÃû)+1,CHARINDEX('.',×Ö¶ÎÃû,CHARINDEX('.',×Ö¶ÎÃû)+1)-CHARINDEX('.',×Ö¶ÎÃû)-1
)
)
as nCount,

SUBSTRING
(
×Ö¶ÎÃû,
CHARINDEX('.',×Ö¶ÎÃû)+1,CHARINDEX('.',×Ö¶ÎÃû,CHARINDEX('.',×Ö¶ÎÃû)+1)-CHARINDEX('.',×Ö¶ÎÃû)-1
)
as address

from ±íÃû

GROUP BY
SUBSTRING
(
×Ö¶ÎÃû,
CHARINDEX('.',×Ö¶ÎÃû)+1,
CHARINDEX('.',×Ö¶ÎÃû,CHARINDEX('.',×Ö¶ÎÃû)+1)-CHARINDEX('.',×Ö¶ÎÃû)-1
)

order by count(*) desc



SQL code:

mysql> select * from url;
+-------------------------------+
| url |
+-------------------------------+
| http://www.baidu.com/ |
| http://www.baidu.com/a/b/c/d/ |
| http://www.sina.com


Ïà¹ØÎÊ´ð£º

SQL serverÊý¾Ý¼¯³ö´íÇóÖú

Á½ÖÖ´íÎó£º
1.Èç¹ûÎÒÕâÑùÉêÃ÷£ºResultSet rs;´íÎóÌáʾÈçÏ£º

An error occurred at line: 51 in the jsp file: /index.jsp
The local variable rs may not have been initialized
48:    ......

SQLÓï¾äÎÊÌ⣬¸ßÊÖ°ï棡£¡

½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿

21-30ÊÇʲôÒâ˼£¿×ֶεĻ°¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......

Ò»µÀSqlÃæÊÔÌâÇó½â

Êý¾Ý¿â ÏÖÔÚÓбí1£¬±í2ÈçÏ£¬ÒªÇóÊä³ö±í3µÄÑù×Ó

Table1

yue  dep  yj

Ò»Ô  1    10

¶þÔ  1    20

ÈýÔ  2  &nb ......

SQLÊý¾Ý¿âÒÉÄÑÎÊÌâ

¼ÙʹÓбíA                                              ¼ÙʹÓбíB

Name  & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ