Èç¹ûдµÝ¹ésqlÓï¾ä - MS-SQL Server / Ó¦ÓÃʵÀý
ÓÐÁ½¸öͬÑùµÄ±í½á¹¹
±í½á¹¹ÈçÏ£º
id£¨ÐòºÅ£© parentid £¨¸¸½áµãÐòºÅ£© name(½áµãÃû³Æ)
±í1 ¼Ç¼ 1 0 aaa
2 0 bbb
3 1 ccc
¡£¡£¡£¡£¡£¡£
±í2 ¼Ç¼
1 0 bbb
2 0 xxx
¡£¡£¡£¡£
±í1Óë±í2¶¼ÊÇÊ÷×´½á¹¹¼Ç¼¡£ÏÖÐèÒª½«±í1¼Ç¼µ¼Èëµ½±í2ÖÐ £¬±í2ÖÐÒѾÓв¿·Ö¼Ç¼£¬ÓÐЩ¼Ç¼Óë±í1ÖмǼÏàͬ¡£
ÏÖÐèÒª½«±í1ÖеļǼµ¼Èëµ½±í2ÖУ¬ÐèÒªÅжϱí2ÖÐûÓбí1¼Ç¼µÄÐèҪȫ²¿µ¼È룬²¢ÇÒÊ÷×´½á¹¹ºÍ±í1ÖеĽṹһÖ¡£
Óô洢¹ý³ÌÒ²¿ÉÒÔ¡£Ð»Ð»¡£
MRAK »ØÈ¥ÔÙ¿´
¶¥ÏÂ
SQL code:
insert into ±í2
select * from ±í1 a where not exists
(select 1 from ±í2 b where a.id=b.id and a.parentid=b.parentid and a.name=b.name)
¿ÉÒÔ³¢ÊÔ
Ŷ ЧÂʰ¡Ð§ÂÊ
ÔÀ´ÕâÑùÕæµÄ¿ÉÒÔ¡£¡£ÏëÁË¡£Ã»
Ïà¹ØÎÊ´ð£º
½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿
21-30ÊÇʲôÒâ˼£¿×ֶεϰ¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......
±íÈçÏÂ
½ÌÊÒID ×ùλÊý ¿ªÊ¼Ê±¼ä ½áÊøÊ±¼ä 2009Äê1ÔÂ1ÈÕ 2009Äê1ÔÂ2ÈÕ 2009Äê1ÔÂ3ÈÕ
101 50 08£º00 08£º30 30 40 50
101 50 09£º00 ......
Èç¹ûÓÃsqlÓï¾ä¸ü¸Älj×ֶεÄ·¾¶£¬ÈçÏ£º
lj
7/200781616183095962.jar
8/f_200812111413292.jar
8/f_200812111413291.jar
µÃµ½µÄ½á¹ûÈçÏ£º
lj
1/7/200781616183095962.jar
1/8/f_20081 ......
ÎÒÒ»¸öÏîÄ¿£¬Óиö²åÈë²Ù×÷£¬¾ßÌåÊÇÕâÑùµÄ£º
ÎÒÓнø»õÐÅÏ¢±í¡£ÔÚ³ö»õʱѡÔñÏàÓ¦µÄ½ø»õÐÅÏ¢£¬ÊäÈëÊýÁ¿£¬Ñ¡Ôñ²¿Ãź󣬵㱣´æ°´Å¥£¬ÓÉÓÚÍøÂçÑÓʱ£¬µãÒ»ÏÂûÓз´Ó³£¬ÓÚÊÇÓû§¾ÍÓÖµãһϣ¬µ¼ÖÂÒ»´Î²åÈëÁËÁ½Ìõ¼Ç¼:
Àý£º
......
ÓÐÒ»Õűí(SHGL)
JLBH LXR LXDH SHDZ
1 a ......