Çó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
Ö§³Ö
ѧϰ
×îºó²»ÒªÓô¥·¢Æ÷ÁË,ÓÃÍâ¼ü¹ØÁª,ÊÖ¶¯Ìí¼Ó.·½±ãʵÓÃ,ά»¤Ò²ºÜºÃ
Ïà¹ØÎÊ´ð£º
ÓÐÒ»¸ö±íAA
name tj
1 a
1 b
1 c
2 a
2 d
3 b
ÒªÇóµ±tj×ֶεÄÖµ¼ÈµÈÓÚaÓÖµÈÓÚcʱ£¨tj = ¡®a¡ ......
×ÜÊý±í
×Ö¶Î num,freq
numÊÇËùÊôÆÚµÄ×ÜÊý£¬freqÊǼǼ¸ÃÊýÖµËùÊôÄÄÒ»ÆÚµÄ
ÇøÓò±í
×Ö¶Î area_name,tot,freq
ÇøÓòÃû³Æ£¬¸ÃÇøÓòµÄ×ÜÊý£¬ËùÊôÆÚ
Á½ÕÅ±í¿¿freq¹ØÁª£¬ÇÒ²»ÊÇ×ÔÔö×ֶΣ¬²»ÊÇÖ ......
µã»÷¡°·þÎñ¹ÜÀíÆ÷¡±£¬µã»÷¡°¿ªÊ¼/¼ÌÐø¡±£¬×ÜÊÇÏÔʾ¡°ÓÉÓڵǼʧ°Ü¶øÆô¶¯·þÎñ¡±£¬È»ºóÔٴγö´í£¬²»Äܹ»½øÈ룬Ҳ²»Äܹ»²é¿´ÊôÐÔ£¬ÇëÎÊ´ó¼Ò¸ÃÔõô°ì£¿
ÎÒÊDzſªÊ¼Ñ§Ï°Êý¾Ý¿â£¬ÇëÎÊ´ó¼ÒÓÐûÓÐʲôºÃһЩµÄ½¨Òé»òÕ ......
±ÈÈç ÎÒÓÐÒ»¸ö±í bumen
ÀïÃæ ÓÐÒ»¸öÁÐ quanxian
id name quanxian
1 a 001;002;003;
2 b 002;003;
3 ......
Êý¾Ý¿âij±í£¬Ï뽫ÆäÖÐf1,f2Á½¸ö×ֶεÄÄÚÈÝ·10±¶£¬Çë½ÌÈçºÎд·¨£¿
update tbl set f1= f1*10£¬f2= f2*10 where id=10451
ÕâÖÖд·¨»áÔì³Éplsql¿¨ËÀ
²»»á°É£¬ÄǸöid=10451 µÄÊý¾ÝÓжàÉÙ°¡~~~~
ÎÒ¹À¼ÆsqlÊDz» ......