Èç¹ûдµÝ¹é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)
¿ÉÒÔ³¢ÊÔ
Ŷ ЧÂʰ¡Ð§ÂÊ
ÔÀ´ÕâÑùÕæµÄ¿ÉÒÔ¡£¡£ÏëÁË¡£Ã»
Ïà¹ØÎÊ´ð£º
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......
select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......
ÎÒµÄTblworkbill±íµÄÊý¾ÝÈçÏÂ:
id workbillno ..................
1 1
2 6
3 a1
4 c2
5 2
6 aa
7 ......
pl/SqlÈçºÎ²éѯ×Ö·û´®°üÀ¨%,
ÀýÈç:TABLE a
columnA
'222'
'33%44'
ÈçºÎ²éѯ±íaÖÐcolumnA×Ö¶ÎÖÐÄÄЩÐаüº¬'%'
лл
select * from a
where columna like '%/%%' escape '/'
UP
SELECT * from a ......