SQLÁ·Ï°
father±í son±í
fid fname sid sname fid height money
1 a 100 s1 1 1.7 7000
2 b 101 s2 2 1.6 8000
3 c 102 s3 2 1.8 9000s
create table father(
fid number primary key,
fname varchar(10)
);
create table son(
sid number primary key,
sname varchar(10),
fid number,
height number,
money number
);
select t.*, t.rowid from father t;
select t.*, t.rowid from son t;
1¡¢²éѯsid¡¢sname¡¢fid
select sid,sname,fid from son;
2¡¢²éѯ¸÷¶ù×ÓÕǼÛ20%ÒÔºóµÄÐÂѧ·Ñ,×¢Òâ,8000¿éÒÔϵIJ»ÕǼۡ£
select money*1.2 as new_money from son where money>=8000
union all
select money from son where money<8000;
select 'ÕÇÁË' as ÕǼÛÇé¿ö,money*1.2 as new_money from son where money>=8000
union all
select 'ûÕÇ',money from son where money<8000;
select money,money*1.2 as new_money from son where money>=8000
union all
select money,null from son where money<8000;
select son.*,(case when money<8000 then money
when money>=8000 then money*1.2 end)as new_money
from son;
--º¯Êý
create or replace function f_get_new_money(p_money son.money%type)
return number
as
begin
if(p_money>=8000)then
return p_money*1.2;
else
return p_money;
end if;
end;
select son.*,scott.f_get_new_money(money) as new_money from son;
--Ò»Ìâ¶à½â£¬ÏÂÃæµÄÌâÄ¿Ò²ÊÇ°´ÕÕÕâÖÖ˼·£¨1.ÓÃSQL 2.Èç¹û×ö²»À´£¬Óú¯ÊýÒ»¶¨¿ÉÒÔ£©
3¡¢²éѯsid¡¢sname¡¢fname¡£
--Óï·¨ from t1 join t2 on t1.id=t2.id
SELECT s.sid,s.sname,f.fname
from father f JOIN son s ON f.fid=s.fid;
Ïà¹ØÎĵµ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Dat ......
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......
ASPµ÷Óô洢¹ý³ÌµÄ·½·¨£º
---- ¡¡¡¡µ÷Óô洢¹ý³ÌµÄ·½·¨ÐèҪʹÓÃADOµÄCommand¶ÔÏó¡£Command¶ÔÏóÊǶÔÒ»¸öÊý¾ÝÔ´ÔËÐÐÌض¨ÃüÁîµÄ¶¨Ò壨ÀýÈ磬һ¸öSQL²éѯ»òÒ»¸öSQL´æ´¢¹ý³Ì£©¡£ÏÂÃæÒÔMS SQL SERVER6.5Ϊºǫ́Êý¾Ý¿â£¬½éÉÜASPµ÷Óô洢¹ý³ÌµÄ·½·¨¡£
---- ¡ ......
µ÷ÊÔ:
ÔÚSQL QUERYÖЗ¡·¶ÔÏóä¯ÀÀÆ÷—¡·´æ´¢¹ý³Ì—¡·Ñ¡ÔñÒªµ÷ÊԵĴ洢¹ý³Ì—¡·ÓÒ»÷—¡·Ñ¡Ôñµ÷ÊÔ£¨debug£©—¡·ÊäÈë²ÎÊý—¡·--ÉèÖÃÍêÄãµÄ²ÎÊýÖµºó--µã»÷Ö´ÐУ¬¾ÍÊdzöÏÖÒ»¸ö¸¡¶¯¹¤¾ßÌõ£¬ÉÏÃæÓе¥²½Ö´ÐУ¬¶ÏµãÉèÖõÈ
---¸ú×Ù :
¿ªÊ¼->³ÌÐò->MS SQLSERVER->ʼþ̽²éÆ÷(SQL Prof ......