SQL ¸üÐÂÓï¾ä - MS-SQL Server / ÒÉÄÑÎÊÌâ
±í1 µ¥ºÅ ÈÕÆÚ 001 2010-01-01 002 2020-01-02 ±í2 µ¥ºÅ »õÎï µ¥¼Û 001 Êé±¾ 10 002 ÒÎ×Ó 80 ÎÊ: ÈçºÎÓÃsql Óï¾ä¸üÐÂÈÕÆÚΪ2010-01-01µÄÊé±¾µÄµ¥¼ÛΪԵ¥¼Û*2?
SQL code: update ±í2 set µ¥¼Û=µ¥¼Û*2 from ±í1 a join ±í2 b on a.µ¥ºÅ=b.µ¥ºÅ and a.ÈÕÆÚ='2010-01-01' SQL code: create table t1(num varchar(5),ddate datetime) create table t2(num varchar(5),product varchar(100),price int) insert into t1 select '001','2010-01-01' union select '002','2020-01-02' insert into t2 select '001','Êé±¾',10 union select '002','ÒÎ×Ó',80 select * from t2 update t2 set price=price*2 where num=(select num from t1 where ddate='2010-01-01') select * from t2 drop table t1 drop table t2ÒýÓà ±í1 µ¥ºÅ ÈÕÆÚ 001 2010-01-01 002 2020-01-02 ±í2 µ¥ºÅ »õÎï µ¥¼Û 001 Êé±¾ 10 002 ÒÎ×Ó 80 ÎÊ: ÈçºÎÓÃsql Óï¾ä¸üÐÂÈÕÆÚΪ2010-01-01µÄÊé±¾µÄµ¥¼ÛΪԵ¥¼Û*2? SQL code: update ±í2 set µ¥¼Û=µ¥¼Û*2 where exists(sele
Ïà¹ØÎÊ´ð£º
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ ÀýÈç£ ......
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£ ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î date(Ö÷) outid(Ö÷) inid(Ö÷) num amt 2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£© tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname ½á¹û£º µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......