Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sqlÓï¾äÅжϲ»Îª¿ÕÔõôд

declare @temp int £¨×¢Ò⣺Õâ¸ö@tempÊÇÕÒ²»µ½ÈκÎÖµµÄ£©
set @temp=(select * from a where id=1)
if(@temp Õâ¸öλÖÃÈçºÎÅжÏ)
update B set name=ll where .....
in not null

  IF @temp IS NOT NULL AND @temp != '' 

intµÄ¿ÕÓ¦¸ÃÊÇ0

is not null

»òÊÇ is null ¶¼ÊÔϰÉ

  £¡=Null

!=null    is null

is not null

is not null

IF @temp IS NOT NULL AND @temp != '' 

ÊÔ¹ýÁË is not null , is null, <>0  ¶¼³öÏÖÁË´íÎó
´íÎóÈçÏ£º×Ó²éѯ·µ»ØµÄÖµ¶àÓÚÒ»¸ö¡£µ±×Ó²éѯ¸úËæÔÚ  =¡¢!=¡¢ <¡¢ <=¡¢>¡¢>=  Ö®ºó£¬»ò×Ó²éѯÓÃ×÷±í´ïʽʱ£¬ÕâÖÖÇé¿öÊDz»ÔÊÐíµÄ¡£ 
¿ÉÒԿ϶¨@temp ÊÇûÓÐÖµµÄ

.........
set @temp=(select * from a where id=1)
ÄãÕâÀï·µ»Ø¶à¸ö×Ö¶ÎÁË..... select  ×Ö¶Î from a where id=1

if(@temp !=0)

is not null

if(@temp is not null and @temp!=0)

Â¥ÉϵIJ»´í

is not null

Óï·¨ÎÊÌâʹÓÃÁÙʱ±í
»òselect isnull(×Ö¶Î,0) from Tb

ÆäʵÄãµÄ¸ÄΪһÌõÓï¾ä¾ÍÐÐÁË


update B set name=ll where ..... and exists(select * from a where id=1)

intÐͲÎÊýÄãÔõô¿ÉÄܰÑÒ»¸ö¼¯ºÏ¸³¸øËü¡­¡­
´íÎóÌáʾҲÒѾ­ºÜÇå³þÁË
declare @temp int
set @temp=select count(1) from a where id=1
if(@temp >0)
update B set name=ll where .....

19Â¥Õý½â



Ïà¹ØÎÊ´ð£º

SQLÓï¾äЧÂÊÎÊÌâ - ÆäËûÊý¾Ý¿â¿ª·¢ / ÆäËûÊý¾Ý¿â

´ó¼Ò°ïæ¿´¿´Õâ2¸ösqlÓï¾äÄĸö²éѯµÄËٶȸü¿ìµã¡£Ð»Ð»°ïæ¡£±È½Ï׿±¡£ÔÚ×öÐÔÄܲâÊÔ¡£
select * from
  ±íA LEFT OUTER JOIN ±íB ON (±íA.id || ' ' =±íB.id) ,±íC , ±íD, ±íE
WhereÆäËûÌõ¼þ
select * ......

sqlÓï¾ä¶à±í¶à×ֶβéѯ - MS-SQL Server / »ù´¡Àà

ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд 

ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......

ÇóÒ»sql¡¾Ð»Ð»¡¿ - MS-SQL Server / »ù´¡Àà

ÐèÇóÈçÏ£º
a±í:
 p_id status  
  1 0
  2 0
b±í
rec_id pid purchase_qty receive_qty flag
1 1 10 10 0
2 ......

Ò»ÌõsqlÓï¾ä - MS-SQL Server / »ù´¡Àà

Course(C#,Cname,T#) ¿Î³Ì±í 
SC(S#,C#,score) ³É¼¨±í 
Teacher(T#,Tname) ½Ìʦ±í 
ÌâÄ¿£º°Ñ¡°SC¡±±íÖС°Ò¶Æ½¡±ÀÏʦ½ÌµÄ¿ÎµÄ³É¼¨¶¼¸ü¸ÄΪ´Ë¿Î³ÌµÄƽ¾ù³É¼¨£» 
 update SC set sco ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ