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

Çósql´¥·¢Æ÷Óï¾ä

users±í
name  companyId  companyName


company±í
companyId  companyName
1          a¹«Ë¾
2          b¹«Ë¾

µ±Ìí¼Óuser±íʱ,¸ú¾ÝËùÌîµÄusers.comapnyId,Óô¥·¢Æ÷²úÉúusers.companyName¶ÔÓ¦µÄcompany±íµÄcompanyNameÖµ


select companyName from company where companyId =@companyId 

SQL code:
create trigger tri_users_insert
on users
instead of insert
as
begin
insert users
select i.name,i.companyId,c.companyName
from inserted i,company c
where i.companyId=c.companyId
end

»òÕß²»ÓÃinstead of£¬²åÈëºóÓô¥·¢Æ÷½øÐиüÐÂ

SQL code:
create trigger tri_users_insert
on users
after insert
as
begin
update u
set u.companyName=c.companyName
from users u,inserted i,company c
where i.companyId=c.companyId and i.companyId=u.companyId
end


Ö§³Ö

ѧϰ

×îºó²»ÒªÓô¥·¢Æ÷ÁË,ÓÃÍâ¼ü¹ØÁª,ÊÖ¶¯Ìí¼Ó.·½±ãʵÓÃ,ά»¤Ò²ºÜºÃ


Ïà¹ØÎÊ´ð£º

sqlÓï¾äÎÊÌâ

ÓÐÒ»¸ö±íAA
name  tj
1    a
1    b
1    c
2    a
2    d
3    b
ÒªÇóµ±tj×ֶεÄÖµ¼ÈµÈÓÚaÓÖµÈÓÚcʱ£¨tj = ¡®a¡ ......

ÇóSQL¡«¡«¡«¡«¡«

×ÜÊý±í
×Ö¶Î num,freq
numÊÇËùÊôÆÚµÄ×ÜÊý£¬freqÊǼǼ¸ÃÊýÖµËùÊôÄÄÒ»ÆÚµÄ


ÇøÓò±í
×Ö¶Î area_name,tot,freq
ÇøÓòÃû³Æ£¬¸ÃÇøÓòµÄ×ÜÊý£¬ËùÊôÆÚ

Á½ÕÅ±í¿¿freq¹ØÁª£¬ÇÒ²»ÊÇ×ÔÔö×ֶΣ¬²»ÊÇÖ ......

sql server 2000 µÇ¼ʧ°Ü

µã»÷¡°·þÎñ¹ÜÀíÆ÷¡±£¬µã»÷¡°¿ªÊ¼/¼ÌÐø¡±£¬×ÜÊÇÏÔʾ¡°ÓÉÓڵǼʧ°Ü¶øÆô¶¯·þÎñ¡±£¬È»ºóÔٴγö´í£¬²»Äܹ»½øÈ룬Ҳ²»Äܹ»²é¿´ÊôÐÔ£¬ÇëÎÊ´ó¼Ò¸ÃÔõô°ì£¿

ÎÒÊDzſªÊ¼Ñ§Ï°Êý¾Ý¿â£¬ÇëÎÊ´ó¼ÒÓÐûÓÐʲôºÃһЩµÄ½¨Òé»òÕ ......

ÇóSQLÒ»ÌõÓï¾äµÄ½â¾ö·½·¨

±ÈÈç ÎÒÓÐÒ»¸ö±í bumen

ÀïÃæ ÓÐÒ»¸öÁР quanxian
id  name  quanxian

1    a    001;002;003;
2    b    002;003;
3    ......

ÇósqlÓï¾ä½«Êý¾Ý¿â±íijЩ×ֶεÄÄÚÈÝ·­10±¶

Êý¾Ý¿âij±í£¬Ï뽫ÆäÖÐf1,f2Á½¸ö×ֶεÄÄÚÈÝ·­10±¶£¬Çë½ÌÈçºÎд·¨£¿
update tbl set f1= f1*10£¬f2= f2*10 where id=10451
ÕâÖÖд·¨»áÔì³Éplsql¿¨ËÀ
²»»á°É£¬ÄǸöid=10451 µÄÊý¾ÝÓжàÉÙ°¡~~~~

ÎÒ¹À¼ÆsqlÊDz» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ