SQL Ä£ºý²éѯ
ÔÚ½øÐÐÊý¾Ý¿â²éѯʱ£¬ÓÐÍêÕû²éѯºÍÄ£ºý²éѯ֮·Ö¡£
Ò»°ãÄ£ºý²éѯÓï¾äÈçÏ£º
SELECT ×ֶΠfrom ±í WHERE ij×ֶΠLike Ìõ¼þ
ÆäÖйØÓÚÌõ¼þ£¬SQLÌṩÁËËÄÖÖÆ¥Åäģʽ£º
1£¬%
£º±íʾÈÎÒâ0¸ö»ò¶à¸ö×Ö·û¡£¿ÉÆ¥ÅäÈÎÒâÀàÐͺͳ¤¶ÈµÄ×Ö·û£¬ÓÐЩÇé¿öÏÂÈôÊÇÖÐÎÄ£¬ÇëʹÓÃÁ½¸ö°Ù·ÖºÅ£¨%%£©±íʾ¡£
±ÈÈç SELECT * from [user] WHERE u_name LIKE '%Èý%'
½«»á°Ñu_nameΪ“ÕÅÈý”£¬“ÕÅèÈý”¡¢“Èý½Å蔣¬“ÌÆÈý²Ø”µÈµÈÓГÈý”µÄ¼Ç¼ȫÕÒ³öÀ´¡£
ÁíÍ⣬Èç¹ûÐèÒªÕÒ³öu_nameÖмÈÓГÈý”ÓÖÓГ蔵ļǼ£¬ÇëʹÓÃandÌõ¼þ
SELECT * from [user] WHERE u_name LIKE '%Èý%' AND u_name LIKE '%è%'
ÈôʹÓà SELECT * from [user] WHERE u_name LIKE '%Èý%è%'
ËäÈ»ÄÜËÑË÷³ö“Èý½Å蔣¬µ«²»ÄÜËÑË÷³ö·ûºÏÌõ¼þµÄ“ÕÅèÈý”¡£
2£¬_
£º ±íʾÈÎÒâµ¥¸ö×Ö·û¡£Æ¥Åäµ¥¸öÈÎÒâ×Ö·û£¬Ëü³£ÓÃÀ´ÏÞÖƱí´ïʽµÄ×Ö·û³¤¶ÈÓï¾ä£º
±ÈÈç SELECT * from [user] WHERE u_name LIKE '_Èý_'
Ö»ÕÒ³ö“ÌÆÈý²Ø”ÕâÑùu_nameΪÈý¸ö×ÖÇÒÖмäÒ»¸ö×ÖÊÇ“Èý”µÄ£»
ÔÙ±ÈÈç SELECT * from [user] WHERE u_name LIKE 'Èý__';
Ö»ÕÒ³ö“Èý½Åè”ÕâÑùnameΪÈý¸ö×ÖÇÒµÚÒ»¸ö×ÖÊÇ“Èý”µÄ£»
3£¬[ ]
£º±íʾÀ¨ºÅÄÚËùÁÐ×Ö·ûÖеÄÒ»¸ö£¨ÀàËÆÕýÔò±í´ïʽ£©¡£Ö¸¶¨Ò»¸ö×Ö·û¡¢×Ö·û´®»ò·¶Î§£¬ÒªÇóËùÆ¥Åä¶ÔÏóΪËüÃÇÖеÄÈÎÒ»¸ö¡£
±ÈÈç SELECT * from [user] WHERE u_name LIKE '[ÕÅÀîÍõ]Èý'
½«ÕÒ³ö“ÕÅÈý”¡¢“ÀîÈý”¡¢“ÍõÈý”£¨¶ø²»ÊÇ“ÕÅÀîÍõÈý”£©£»
Èç [ ] ÄÚÓÐһϵÁÐ×Ö·û£¨01234¡¢abcdeÖ®ÀàµÄ£©Ôò¿ÉÂÔдΪ“0-4”¡¢“a-e”
SELECT * from [user] WHERE u_name LIKE 'ÀÏ[1-9]'
½«ÕÒ³ö“ÀÏ1”¡¢“ÀÏ2”¡¢……¡¢“ÀÏ9”£»
4£¬[^ ]
£º±íʾ²»ÔÚÀ¨ºÅËùÁÐÖ®Äڵĵ¥¸ö×Ö·û¡£ÆäÈ¡ÖµºÍ [] Ïàͬ£¬µ«ËüÒªÇóËùÆ¥Åä¶ÔÏóΪָ¶¨×Ö·ûÒÔÍâµÄÈÎÒ»¸ö×Ö·û¡£
±ÈÈç SELECT * from [user] WHERE u_name LIKE '[^ÕÅÀîÍõ]Èý'
½«ÕÒ³ö²»ÐÕ“ÕÅ”¡¢“À¢“Íõ”µÄ“ÕÔÈý”¡¢“ËïÈý”µÈ£»
SELECT * from [user] WHERE u_name LIKE 'ÀÏ[^1-4]';
½«Åųý“ÀÏ1”µ½“ÀÏ4”£¬Ñ°ÕÒ“ÀÏ5”¡¢“ÀÏ6
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
Global.asaxÎļþÖÐ
ÔÚÒ³ÃæÌøתʱ£¬·ÀÖ¹´«ÖµµÄ²ÎÊýÖÐSQL×¢È룺
void Application_BeginRequest(object sender, EventArgs e)
{
ProcessRequest();
}
void ProcessRequest()
{
try
......
SQL ServerÖе÷Ó÷½·¨Ê±£¬¾³£Óöµ½.»òÊÇ::Á½ÖÖµ÷Ó÷½·¨£¬ÆäÖÐ. ÊÇʵÀýµ÷Ó÷½·¨£¬::ÊǾ²Ì¬µ÷Ó÷½·¨¡£Èç¹û´ó¼Ò¶ÔC#Óï·¨ÊìϤµÄ»°£¬. ¶ÔÓ¦C#Öе÷ÓÃʵÀý·½·¨£¬:: ¶ÔÓ¦C#ÖеÄstatic·½·¨¡£
ÏÂÃæ¸ø³öÒ»¸öSQL ServerµÄʵÀý£¬ÏÂÃæµÄSQLÔËÐÐÔÚ2008»·¾³Ï£º
DECLARE @g geography;
SET @g = geography::Parse('LINESTRING(-122.360 ......
³£Óô洢¹ý³Ì¼¯½õ,¶¼ÊÇһЩmssql³£ÓõÄһЩ£¬´ó¼Ò¿ÉÒÔ¸ù¾ÝÐèҪѡÔñʹÓá£
¡¡¡¡=================·ÖÒ³==========================
¡¡¡¡/*·ÖÒ³²éÕÒÊý¾Ý*/
¡¡¡¡CREATE PROCEDURE [dbo].[GetRecordSet]
¡¡¡¡@strSql varchar(8000),--²éѯsql,Èçselect * from [user]
¡¡¡¡@PageIndex int,--²éѯµ±Ò³ºÅ
¡¡¡¡@PageSize ......
ISNULL
²éѯÊý¾ÝʱÈô×Ö¶ÎÖµÊÇNULL£¬ÔòʹÓÃʹÓÃÖ¸¶¨µÄÌæ»»ÖµÌæ»» NULL¡£
Óï·¨
ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_value
ÔÚ check_expression Ϊ NULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ± ......