¹ØÓÚsql where id in ת»»³ÉÊý¾ÝÀàÐÍ int ʱʧ°Ü
ÓÐÖ´ÐÐsqlÌõ¼þÓï¾äwhere id in(@²ÎÊý)µÄʱºò£¬Èç¹û´¦Àí²»µ±£¬¾Í»á³öÏÖÎÊÌ⣺
ÈçÏÂÃæÕâ¸ö´æ´¢¹ý³Ì£º
alter proc Web_gettwtwgoldgameserverGoldSell
@ID int
as
declare @twgoldsellID nvarchar(1000)
select @twgoldsellID=twgoldsellID from twgoldgameserver where ID=@ID
set @twgoldsellID=replace(@twgoldsellID,'|',',')
set @twgoldsellID=left(@twgoldsellID,len(@twgoldsellID)-1)
select * from twgoldsell where ID in (@twgoldsellID)
ÎÒÃÇ¿´ÉÏÈ¥ºÃÏñûÓÐʲôÎÊÌ⣬ȴÔÚÖ´ÐеÄʱºò±¨´í£º
ÏûÏ¢ 245£¬¼¶±ð 16£¬×´Ì¬ 1£¬µÚ 1 ÐÐ
ÔÚ½« varchar Öµ '813,1160,1219,1227,1232' ת»»³ÉÊý¾ÝÀàÐÍ int ʱʧ°Ü¡£
Æäʵ´ËÌõÓï¾äÔÚÖ´ÐÐʱ,
select * from twgoldsell where ID in (@twgoldsellID)
Ö´ÐеÄÓï¾äÊÇ£ºselect * from twgoldsell where ID in ('813,1160,1219,1227,1232')
ÕâÑùÖ´Ðе±È»³ö´í£¬ÒòΪ@twgoldsellIDÊÇÒ»¸ö×Ö·û´®£¬ÏÖÔÚÊÇÒÔ²ÎÊýµÄÐÎʽ´«µÝ¡£
½â¾ö°ì·¨£º
select * from twgoldsell where ID in (@twgoldsellID)
¸ÄΪ:
exec('select * from twgoldsell where ID in ('+@twgoldsellID+')')
¼Çס£ºÒ»¶¨Òª¼ÓexecÖ´Ðк¯Êý£¬²»È»»á±¨ÈçÏ´íÎó£º
ÏûÏ¢ 245£¬¼¶±ð 16£¬×´Ì¬ 1£¬¹ý³Ì Web_gettwtwgoldgameserverGoldSell£¬µÚ 8 ÐÐ
ÔÚ½« varchar Öµ '+@twgoldsellID+' ת»»³ÉÊý¾ÝÀàÐÍ int ʱʧ°Ü¡£
¹ØÓÚsqlÌõ¼þÓï¾äwhere id in (@²ÎÊý)Ö´Ðб¨´íÎÊÌâ(ת»»³ÉÊý¾ÝÀàÐÍ int ʱʧ°Ü)½â¾öÍê³É£¬ÓÐʲôÎÊÌ⣬¿ÉÒÔÒ»ÆðÔÚ¼¼ÊõÉçÇø(http://bbs.25yi.com)ÌÖÂÛ¡£
×÷Õß: ÍøÕ¾Éè¼Æ@ ÆóÒµÍøÕ¾¹ÜÀíϵͳ
ÔÔØ: 25ÒÚÆóÒµÍøÕ¾¹ÜÀíϵͳ
Ïà¹ØÎĵµ£º
SQLServerºÍOracleµÄ³£Óú¯Êý¶Ô±È
¡¡¡¡1.¾ø¶ÔÖµ
¡¡¡¡S:select abs(-1) value
¡¡¡¡O:select abs(-1) value from dual
¡¡¡¡2.È¡Õû(´ó)
¡¡¡¡S:select ceiling(-1.001) value
¡¡¡¡O:select ceil(-1.001) value from dual
¡¡¡¡3.È¡Õû£¨Ð¡£©
¡¡¡¡S:select floor(-1.001) value
¡¡¡¡O:select floor(-1.001) value fr ......
select *
from (
select soft.NETMODEL,
soft.softname,
soft.softid ......
SQL SERVER 2008 Òì²½²¶»ñ±íÊý¾ÝÐÞ¸Ä
дµÄ²»¶ÔµÄµØ·½Çë¸÷λָÕý£¬Ð´µÄÒ²±È½ÏÂÒ¡£½²¾¿Õâ¿´°É¡£^ ^
/*
SQL SERVER 2008 Òì²½²¶»ñ±íÊý¾ÝÐÞ¸Ä
SQL server 2008ΪÒì²½¸ú×ÙËùÓз¢ÉúÔÚÓû§±íÉϵÄÊý¾ÝÐÞ¸ÄÌṩÁËÄÚ½¨µÄ·½·¨,
¶ø²»ÐèÒª±àд×Ô¶¨ÒåµÄ´¥·¢Æ÷»òÕß²éѯ,±ä¸üÊý¾Ý²¶»ñÓµÓÐ×îСÐÔÄÜ¿ªÏú,¿ÉÒÔ
Ó ......
1£©²»Öª´ó¼ÒÊÇ·ñϲ»¶Ê¹ÓÑNOT IN’ÕâÑùµÄ²Ù×÷£¬Èç¹ûÊÇ£¬ÄǾ¡Á¿Ê¹ÓÃ(NOT) EXISTS Ìæ´ú
2£©ÔÚº£Á¿²éѯʱ¾¡Á¿ÉÙÓøñʽת»»¡£
3£©²éѯº£Á¿Êý¾ÝÊÇ£¬¿ÉÒÔʹÓÃoptimizer['ɔptimaizə] hints£¬ÀýÈç/*+ORDERED */
¾¡Á¿ÉÙÓÃIN²Ù×÷·û£¬»ù±¾ÉÏËùÓеÄIN²Ù×÷·û¶¼¿ÉÒÔÓÃEXISTS´úÌæ¡£
²»ÓÃNOT IN²Ù×÷·û£¬¿ÉÒÔ ......
µÚÒ»ÖÖ£º
SELECT
CASE
WHEN
price IS NULL THEN
'Not yet priced'
WHEN
price < 10 THEN
'Very Reasonable Title'
WHEN
price >= 10 AND
price < 20 THEN
'Coffee Table Title'
EL ......