Ò»µÀSqlÃæÊÔÌâÇó½â
Êý¾Ý¿â ÏÖÔÚÓбí1£¬±í2ÈçÏ£¬ÒªÇóÊä³ö±í3µÄÑù×Ó
Table1
yue dep yj
Ò»ÔÂ 1 10
¶þÔÂ 1 20
ÈýÔÂ 2 30
Table2
dep dep_name
1 ²¿ÃÅ1
2 ²¿ÃÅ2
3 ²¿ÃÅ3
4 ²¿ÃÅ4
Table3
dep Ò»ÔÂ ¶þÔÂ ÈýÔÂ
1
Table3
dep Ò»ÔÂ ¶þÔÂ ÈýÔÂ
1 10 20 null
2 null null 30
3 null null null
4 null null null
ÐÐתÁÐ
ÐÐתÁмÓÁ¬½Ó±í
SQL code:
if object_id('tb1')is not null drop table tb1
go
create table tb1(yue varchar(10), dep int, yj int)
insert tb1 select
'Ò»ÔÂ' , 1, 10 union all select
'¶þÔÂ', 1 , 20 union all select
'ÈýÔÂ' , 2 , 30
if object_id('tb2')is not null drop table tb2
go
create table tb2( dep int, dep_name varchar(10))
insert tb2 select
1, '²¿ÃÅ1' union all select
2, '²¿ÃÅ2'union all select
3, '²¿ÃÅ3' union all select
4, '²¿ÃÅ4'
select b.dep,
[Ò»ÔÂ]=max
Ïà¹ØÎÊ´ð£º
sql2005
select *from v_ddxx where d_sfsc='0' and (g_ssbm='1001' or g_ssbm='1002') and (xxf>0 and xxfwzf <>0 ),Ö´ÐÐËÙ¶ÈÂýµÄÒªËÀ£¬µ«ÊÇÈç¹û°Ñ(xxf>0 and ......
½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿
21-30ÊÇʲôÒâ˼£¿×ֶεϰ¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......
ÎÒÓÐÒ»¸öÔºÍÈÕ×é³ÉµÄÊý×Ö£¬ÓÐÁ½×éÔºÍÈÕ
ÏëÔÚÉí·ÝÖ¤ºÅÖÐÌôÑ¡³öÔڸøÃÁ½×éÔÂÈÕÖ®¼ä³öÉúµÄÈË£¬²»ÖªµÀÓ¦¸ÃÔõôд.
Éí·ÝÖ¤ºÅÓпÉÄÜÊÇ15λ»òÕß18λ
ÔÂÈÕ×éºÏµÄÐÎʽÈçÏÂ
10-17/04-20
ÔÂ-ÈÕ/ÔÂ- ......
SQL code:
1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb)
SQL: select * into b from a where 1<>1;
2. ˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý£¬Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb)
SQL: insert into b(a ......