ÔÚSQLÓï¾äÖнØÈ¡×Ö·û´®º¯ÊýµÄÓ¦ÓÃ
ÎÊÌâÒ»
ÓÐÕâÑùµÄÒ»¸öÎÊÌ⣬Êý¾Ý¿âÖÐÓÐÁ½¸ö±í£¬·Ö±ðÊÇGuest,Hotel£¬¼´ÂÿÍÐÅÏ¢±íºÍÂùÝÐÅÏ¢±í£¬Guest±íÖÐÓÐÒ»¸öÂÿͱàÂëµÄ×ֶΣ¬Õâ¸ö×ֶεÄÓÐ20룬ËüµÄǰ10λ´ú±íÕâ¸öÂÿÍËùסµÄÂùݣ¬ÏÖÔÚµÄÎÊÌâÊÇÒª¸ù¾ÝGuest±íÖеÄÂÿͱàÂë×Ö¶ÎÐÅÏ¢²éµ½ËûËùסµÄÂùݵÄÃû³ÆºÍÂùݵØÖ·£¡
ÎÊÌâ½â¾ö:
SQL SERVERµÄSQLÓï¾ä£ºselect Guest.ÂÿͱàÂë,Guest.ÂÿÍÐÕÃû,Hotel.ÂùÝÃû³Æ,Hotel.ÂùݵØÖ· from Guest,Hotel where Hotel.ÂùݱàÂë=SubString(Guest.ÂÿͱàÂë,1,10)
OracleµÄSQLÓï¾ä£ºselect Guest.ÂÿͱàÂë,Guest.ÂÿÍÐÕÃû,Hotel.ÂùÝÃû³Æ,Hotel.ÂùݵØÖ· from Guest,Hotel where Hotel.ÂùݱàÂë=SubStr(Guest.ÂÿͱàÂë,1,10)
ÎÊÌâ¶þ
A.½ØÈ¡´Ó×Ö·û´®×ó±ß¿ªÊ¼N¸ö×Ö·û
Declare @S1 varchar(100)
Select @S1='http://www.xrss.cn'
Select Left(@S1,4)
------------------------------------
ÏÔʾ½á¹û: http
B.½ØÈ¡´Ó×Ö·û´®Óұ߿ªÊ¼N¸ö×Ö·û(ÀýÈçÈ¡×Ö·ûwww.163.com)
Declare @S1 varchar(100)
Select @S1='http://www.xrss.cn'
Select right(@S1,11)
------------------------------------
ÏÔʾ½á¹û: www.163.com £¿£¿£¿£¿
C.½ØÈ¡×Ö·û´®ÖÐÈÎÒâλÖü°³¤¶È(ÀýÈçÈ¡×Ö·ûwww)
Declare @S1 varchar(100)
Select @S1='http://www.xrss.cn'
Select SUBSTRING(@S1,8,3)
------------------------------------
ÏÔʾ½á¹û: www.163.com
ÒÔÉÏÀý×Ó½ÔÊÇÒÑÖª½ØÈ¡Î»Öü°³¤¶È,ÏÂÃæ½éÉÜδ֪λÖõÄÀý×Ó
2.½ØÈ¡Î´ÖªÎ»Öõĺ¯Êý
&n
Ïà¹ØÎĵµ£º
¡¾1¡¿
create procedure proc_pager1
( @pageIndex int, -- ҪѡÔñµÚXÒ³µÄÊý¾Ý
@pageSize int -- ÿҳÏÔʾ¼Ç¼Êý
)
AS
BEGIN
declare @sqlStr varchar(500)
set @sqlStr='select top '+con ......
Ò»¡¢±³¾°½éÉÜ
¡¡¡¡
¡¡¡¡½á¹¹»¯²éѯÓïÑÔ(Structured Query Language£¬¼ò³ÆSQL)ÊÇÓÃÀ´·ÃÎʹØÏµÐÍÊý¾Ý¿âÒ»ÖÖͨÓÃÓïÑÔ£¬ÊôÓÚµÚËÄ´úÓïÑÔ£¨4GL£©£¬ÆäÖ´ÐÐÌØµãÊǷǹý³Ì»¯£¬¼´²»ÓÃÖ¸Ã÷Ö´ÐеľßÌå·½·¨ºÍ;¾¶£¬¶øÊǼòµ¥µØµ÷ÓÃÏàÓ¦Óï¾äÀ´Ö±½ÓÈ¡µÃ½á¹û¼´¿É¡£ÏÔÈ»£¬ÕâÖÖ²»¹Ø×¢ÈκÎʵÏÖϸ½ÚµÄÓïÑÔ¶ÔÓÚ¿ª·¢ÕßÀ´ËµÓÐ׿«´óµÄ±ãÀû¡£È»¶ø£¬Ó ......
ÔÚWhere×Ó¾äÖУ¬¿ÉÒÔ¶Ôdatetime¡¢char¡¢varchar×Ö¶ÎÀàÐ͵ÄÁÐÓÃLike×Ó¾äÅäºÏͨÅä·ûѡȡÄÇЩ“ºÜÏñ...”µÄÊý¾Ý¼Ç¼£¬ÒÔÏÂÊÇ¿ÉʹÓõÄͨÅä·û£º
% Áã»òÕß¶à¸ö×Ö·û
_ µ¥Ò»ÈκÎ×Ö·û£¨Ï»®Ïߣ©
\ ÌØÊâ×Ö·û
[] ÔÚijһ·¶Î§ÄÚµÄ×Ö·û£¬Èç ......
µÚÒ»Ìõ£º
select * from where field in (1,2,3) ÕâÖÖд·¨Ó¦¸ÃÉáÆúÁË£¬¶øÓ¦¸ÃÕâÑùд£º
select * from table where field = 1 or field = 2 or field = 3
ÎªÊ²Ã´ÄØ£¿
·²ÊÂÖ»ÓÐ×ö¹ý²ÅÖªµÀ£¬×Ô¼º½¨¸ö±í£¬²åÈë10WÌõ²âÊÔÊý¾Ý£¬ÓÃsql²âÊÔһϱãÖª£¬ÒòΪ¹¤×÷±ãÀû£¬ÎÒÔÚ²úÆ·»úºÍÍâÍø²âÊÔ»ú¶¼ÒѾ²âÊÔ¹ý£ ......
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯
Æ÷ÖÐÓÐЧ)£º
Oracle
µÄ
½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving
table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£¼ÙÈçÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ,
ÄÇ¾Í ......