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

ÇóÒ»sqlÓïÃû

ÏÖÔÚÓÐa1,a2Á½±í
a1

id name aa cc
001 aaaa bbb cc
002 bbb bbb bbb
003 ccc ccc ccc
004 ddd ddd ddd
005 eee eee eee


a2
id ida2 ff bbb
001 01 aaaa cc111
001 02 bbba sdfedl
002 01 bbb aaaa

ҪʵÏÖÒÔϽá¹û£º
001 aaaa bbb cc 001 02 bbba sdfedl
002 bbb bbb bbb 002 01 bbb aaaa
003 ccc ccc ccc null null null null
004 ddd ddd ddd null null null null
005 eee eee eee null null null null

ÃèÊö£ºÈç¹û±ía2ÖÐÓиú ±ía1ÖÐµÄ id×Ö¶ÎÏà¶ÔÓ¦µÄ£¬ÔòÈ¡±ía2ÖÐida2×î´óµÄÏÔʾ£¬
Èç¹û±ía1ÖÐid×Ö¶ÎÓеÄÖµ£¬¶ø±ía2ÖÐûÓиÃÖµ(±ÈÈça1ÖÐid×Ö¶ÎÖÐµÄ 003£¬004£¬005)£¬ÔòÏÔʾa1µÄÖµ£¬±ía2µÄ¸ÃÐÐΪnull
left join

SQL code:
select
a.*,
b.*
from
a1 a
left join
a2 b
on
a.id=b.id
and
not exists(select 1 from a2 where id=b.id and ida2>t.ida2)



ѧϰ£¡


SQL code:
SELECT a1.*,a2.ida2,ff,bb
from a1 a LEFT JOIN a2 b
ON a.id=b.id
WHERE NOT EXISTS(SELECT 1 from a2 WHERE id=b.id AND ida2>b.ida2)


SQL code



Code highlighting


Ïà¹ØÎÊ´ð£º

SQLÓï¾äÎÊÌ⣬¸ßÊÖ°ï棡£¡

½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿

21-30ÊÇʲôÒâ˼£¿×ֶεĻ°¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......

¹ØÓÚSQLSERVERµ×²ãÎÊÌâ - MS-SQL Server / ÒÉÄÑÎÊÌâ

ÇëÎÊһϣ¬ÍâÍøÁ½Ì¨SQLSERVERʵÀýÊý¾Ý´«Ê䣬ÓÐûÓвÉÓÃÊý¾ÝѹËõºÍ¼ÓÃÜ¡£Ñ¹Ëõ±ÈÊǶàÉÙ£¬¼ÓÃÜÊÇʲô¼ÓÃÜËã·¨£¿Ïà¹ØÎĵµÄÄÀï¿ÉÒÔÕÒµ½£¿Ð»Ð»


ÎÒÒ²ÏëÖªµÀ£¡¹Ø×¢´ËÌù£¡

¹Ø×¢¡«¡«

Êý¾Ý¿â´óÅ£¶¼ÄÄÈ¥ÁË°¡£¿
......

sql 語¾ä

±í      TT
×ֶΠ   A1    A2    A3
      1    B    2008/07/09
      2    C  & ......

sql¸üÐÂ×ֶη¾¶

Èç¹ûÓÃsqlÓï¾ä¸ü¸Älj×ֶεÄ·¾¶£¬ÈçÏ£º
lj
7/200781616183095962.jar
8/f_200812111413292.jar
8/f_200812111413291.jar

µÃµ½µÄ½á¹ûÈçÏ£º
lj
1/7/200781616183095962.jar
1/8/f_20081 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ