ʹÓÃSQLÓï¾äÕÒµ½±íÖÐijÁеĵڼ¸Ãû
SQL> select * from t1;
ID AGE
---------- ----------
1 20
2 19
3 19
4 21
5 22
6 27
6 rows selected.
ÏÖÔÚÒªÇóÕÒ³ö±íÖеÚÈýÄêÇáµÄѧÉú
·½·¨1
µÚÈýÄêÇᣬҲ¾ÍÒâζ×ÅÖ»ÓÐÁ½¸öÈ˱ÈËûС
SQL> select t11.*
2 from t1 t11
3 where 2=(select count(*) from t1 t22 where t11.age>t22.age);
ID AGE
---------- ----------
1 20
·½·¨2
ʹÓô°¿Úº¯Êý
SQL> select id,age
2 from
3 (
4 select id,age,
5 dense_rank() over(order by age) dr
6 from t1
7 )
8 where dr=3;
ID AGE
---------- ----------
4 21
Ææ¹ÖÁË£¬ÕâÀï½á¹ûΪʲô²»Ò»ÑùÄØ£¿»ØÍ·¿´Ò»Ï±íÖеÄÊý¾Ý£¬ÓÐÁ½Ìõage=19µÄÊý¾Ý£¬Õâ¾ÍÊÇÔÒò¡£ÏÂÃæ»»rank
SQL> select id,age
2 from
3 (
4 select id,age,
5 rank() over(order by age) dr
6 from t1
7 )
8 where dr=3;
 
Ïà¹ØÎĵµ£º
1. ¶ÔÓÚPHP magic_quotes_gpc=onµÄÇé¿ö£¬ ÎÒÃÇ¿ÉÒÔ²»¶ÔÊäÈëºÍÊä³öÊý¾Ý¿âµÄ×Ö·û´®Êý¾Ý×÷
addslashes()ºÍstripslashes()µÄ²Ù×÷,Êý¾ÝÒ²»áÕý³£ÏÔʾ¡£ Èç¹û´ËʱÄã¶ÔÊäÈëµÄÊý¾Ý×÷ÁËaddslashes()´¦Àí£¬
ÄÇôÔÚÊä³öµÄʱºò¾Í±ØÐëʹÓÃstripslashes()È¥µô¶àÓàµÄ·´Ð±¸Ü¡£ 2. ¶ÔÓÚPHP magic_quotes_gpc=off µÄÇé¿ö ±ØÐëÊ¹Ó ......
table a(id, type):
id type
----------------------------------
1 1
2 1
3 &n ......
²»ÖªµÀÕâÑùµÄÒªÇóÄܲ»ÄÜʵÏÖ£¿
±ÈÈçÎÒÓÐÒ»ÕűíT1£¬ÀïÃæÖ»ÓÐÒ»¸ö×Ö¶Î1
ÀïÃæÓÐ100Ìõ¼Ç¼£¬ÈçÏÂËùʾ£º
×Ö¶Î1
A1
A2
A3
A4
...
A100
ÎÒÏëÓÃÒ»ÌõSQLÏÔʾÕâÑùµÄ½á¹û
µÚÒ»ÁÐ µÚ¶þÁÐ ... µÚÊ®ÁÐ
A1 A11 &nb ......
SQL Server×Ö·û´®´¦Àíº¯Êý´óÈ«
selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'Ô ......