sql CHARINDEX
CHARINDEXº¯Êý·µ»Ø×Ö·û»òÕß×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖеÄÆðʼλÖá£CHARINDEXº¯Êýµ÷Ó÷½·¨ÈçÏ£º
CHARINDEX ( expression1 , expression2 [ , start_location ] )
Expression1ÊÇÒªµ½expression2ÖÐÑ°ÕÒµÄ×Ö·ûÖУ¬start_locationÊÇCHARINDEXº¯Êý¿ªÊ¼ÔÚexpression2ÖÐÕÒexpression1µÄλÖá£
CHARINDEXº¯Êý·µ»ØÒ»¸öÕûÊý£¬·µ»ØµÄÕûÊýÊÇÒªÕÒµÄ×Ö·û´®ÔÚ±»ÕÒµÄ×Ö·û´®ÖеÄλÖ᣼ÙÈçCHARINDEXûÓÐÕÒµ½ÒªÕÒµÄ×Ö·û´®£¬ÄÇôº¯ÊýÕûÊý“0”¡£ÈÃÎÒÃÇ¿´¿´ÏÂÃæµÄº¯ÊýÃüÁîÖ´ÐеĽá¹û£º
CHARINDEX('SQL', 'Microsoft SQL Server')
Õâ¸öº¯ÊýÃüÁ·µ»ØÔÚ“Microsoft SQL Server”ÖГSQL”µÄÆðʼλÖã¬ÔÚÕâ¸öÀý×ÓÖУ¬CHARINDEXº¯Êý½«·µ»Ø“S”ÔÚ“Microsoft SQL Server”ÖеÄλÖÃ11¡£
½ÓÏÂÀ´£¬ÎÒÃÇ¿´Õâ¸öCHARINDEXÃüÁ
CHARINDEX('7.0', 'Microsoft SQL Server 2000')
ÔÚÕâ¸öÀý×ÓÖУ¬CHARINDEX·µ»ØÁ㣬ÒòΪ×Ö·û´®“7.0” ²»ÄÜÔÚ“Microsoft SQL Server”Öб»ÕÒµ½¡£½ÓÏÂÀ´Í¨¹ýÁ½¸öÀý×ÓÀ´¿´¿´ÈçºÎʹÓÃCHARINDEXº¯ÊýÀ´½â¾öʵ¼ÊµÄT-SQLÎÊÌâ¡£
Ïà¹ØÎĵµ£º
SELECT ±íÃû = CASE a.colorder WHEN 1 THEN c.name ELSE '' END,
Ðò = a.colorder,
×Ö¶ÎÃû = a.name,
±êʶ = CASE COLUMNPROPERTY(a.id,a.name, ......
--SQL ²é¿´±¾ÖܵÄÐÇÆÚÒ»ºÍÐÇÆÚÌì
/*
ϵͳµÄʱ¼äĬÈÏ°ÑÐÇÆÚÌì×÷Ϊһ¸öÐÇÆڵĵÚÒ»Ì죬µ«ÊÇÎÒÃÇÖйúÏ°¹ß°ÑÐÇÆÚÒ»×÷Ϊһ¸öÐÇÆڵĵÚÒ»Ì죬Òò´ËÈç¹ûµ±ÌìÊÇÐÇÆÚÌìʱÐèÒªÅжÏÒ»ÏÂ
*/
DECLARE @MondayTime varchar(10)
DECLARE @SundayTime varchar(10)
IF(datepart(weekday,getdate())-2 < 0)
BEGIN
SET @MondayTi ......
ÒòΪ²»Ö§³Ö´æ´¢¹ý³Ì£¬ËùÒÔ²éѯÓï¾äÈçÏ£º
string SLQuery =
"INSERT INTO ParkLocation(ParkName,Latitude, Longtitude,Charge,TotalSpace,EmptySpace,ParkCaption,UpdataTime)"+
&nb ......
SQL JOIN
SQL join ÓÃÓÚ¸ù¾ÝÁ½¸ö»ò¶à¸ö±íÖеÄÁÐÖ®¼äµÄ¹Øϵ£¬´ÓÕâЩ±íÖвéѯÊý¾Ý¡£
Join ºÍ Key
ÓÐʱΪÁ˵õ½ÍêÕûµÄ½á¹û£¬ÎÒÃÇÐèÒª´ÓÁ½¸ö»ò¸ü¶àµÄ±íÖлñÈ¡½á¹û¡£ÎÒÃǾÍÐèÒªÖ´ÐÐ join¡£
Êý¾Ý¿âÖеıí¿Éͨ¹ý¼ü½«±Ë´ËÁªÏµÆðÀ´¡£Ö÷¼ü£¨Primary Key£©ÊÇÒ»¸öÁУ¬ÔÚÕâ¸öÁÐÖеÄÿһÐеÄÖµ¶¼ÊÇΨһµÄ¡£ÔÚ±íÖУ¬Ã¿¸öÖ÷¼üµÄ ......
SQL LEFT JOIN ¹Ø¼ü×Ö
SQL LEFT JOIN ¹Ø¼ü×Ö
LEFT JOIN ¹Ø¼ü×Ö»á´Ó×ó±í (table_name1) ÄÇÀï·µ»ØËùÓеÄÐУ¬¼´Ê¹ÔÚÓÒ±í (table_name2) ÖÐûÓÐÆ¥ÅäµÄÐС£
LEFT JOIN ¹Ø¼ü×ÖÓï·¨
SELECT column_name(s)
from table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
×¢ÊÍ£ºÔÚÄ ......