SQL¸üжàÌõ¼Ç¼
A±í
×Ö¶Î a1 a2 a3
1 2 3
6 2 7
B±í
×Ö¶Î b1 b2 b3
4 5 3
8 9 7
ÎÒÏ뽫 a3Öµ=b3Öµ²¢ÇÒa2=2µÄ¼Ç¼µÄb1Öµ¸üе½a1ÖУ¨±ØÐëÒ»Ò»¶ÔÓ¦£© Ó¦¸ÃÈçºÎ¸üÐÂ
sql = "Update A Set A.a1 = (select B.b3 from B,A where A.a3=B.b3 and A.a2='2') where A.a2='2'"
Ϊʲô²»ÄܸüжàÌõ¼Ç¼
Ò²¾ÍÊÇ˵ ÎÒÏ뽫a1×Ö¶ÎÖеÄ1¸üÐÂΪ4 6¸üÐÂΪ8
Èç¹û²éѯ½á¹ûÖ»ÓÐÒ»Ìõ¼Ç¼ ¿ÉÒÔÕý³£¸üРÈç¹û¼Ç¼Êý´óÓÚ1,Ôò²»ÄܸüÐÂ,ÈçºÎ½â¾ö!~~
SQL code:
UPDATE A SET A1=B1 from B WHERE A.A3=B.B3 AND A.A2=2
SQL code:
update a
set a.a1=b.b1
from a,b
where a.a3=b.b3 and a.a2=2
SQL code:
drop table a;
drop table b;
create table a(a1 int, a2 int, a3 int);
insert into a(a1,a2,a3)
select
1,2,3 union all select
6,2,7;
create table b(b1 int, b2 int, b3 int);
insert into b(b1,b2,b3)
select
4,5,3 union all select
8,9,7;
update a
set a1=b.b1
from a, b
where a.a3=b.b3 and a.a2=
Ïà¹ØÎÊ´ð£º
½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿
21-30ÊÇʲôÒâ˼£¿×ֶεϰ¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......
select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
table1:
uID uName
1 СÀî
2 СÕÅ
table2:
pID uID type
1 1 H1
2   ......