ÇóÖúÒ»ÌõSQL likeÓï¾ä! - .NET¼¼Êõ / ASP.NET
ÇóÖúÒ»ÌõSQL likeÓï¾ä!
table
ID name bran_id
1 ss 1,2
2 aa 10,13
3 cc 1,13,15
µ±bran_id like 1 µÄʱºò£¬½á¹ûÏÔʾµÄÊÇID=1ºÍµÈÓÚ3µÄ£¬¶ø2²»ÏÔʾÒòΪID=2µÄbran_id,ÊÇ10ºÍ13
ÇëÎÊÎÒÕâÌõSQLÓï¾ä¸ÃÔõôд£¿
×Ô¼º¶¥Ò»ÏÂ
bran_id like '%1,%' or '%,1,%' or '%,1%'
string strlike='1'
where ','+bran_id+',' like '%'+ strlike +'%'
string strlike='1'
where ','+bran_id+',' like '%,'+ strlike +',%'
SQL code:
select * from table where bran_id like '%1%'
bran_id like '%1,%' or '%,1,%'
bran_id like '1,%' or '%,1,%'
SQL code:
select * from table where '%ÄãµÄ×Ö·û´®+','%' like bran_id+','
ÎÒ¿´´íÁË£¬ËûÃǵĶÔ
select * from table where bran_id like '%1%'
11
select * from [±íÃû]
where bran_id like '%1,%'
{
Ïà¹ØÎÊ´ð£º
×Ö¶Î1,×Ö¶Î2.....×Ö¶ÎN,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
ÏëÒªµÄ½á¹ûÊÇ:
1,Na ......
¸÷λºÃ£¬ÎÒ¸Õ°ÑÒ»¸öASPÍøÕ¾ÉèÖúÃÁË£¬Ò²ÄÜÕý³£·ÃÎÊ¡£µ«ÊÇÔÚÎÒ±¾»úÉϲ»ÄÜ´ò¿ªadmin\login.asp,ËùÒÔÎÞ·¨ÊµÏÖºǫ́¹ÜÀí¡££¨´íÎóÌáʾÎÞ·¨ÕÒµ½ÍøÒ³£¬´úÂë404£¬ÎҵIJÙ×÷ϵͳÊÇwin2000 server)
µ«ÊÇÆæ¹ÖµÄÊÇÔÚ¾ÖÓòÍøµÄÆäËû» ......
A±í ÓÐÁ½¸ö×Ö¶Î
id ΨһÊý×ÖÓò
InfoTxt text ÀàÐÍ
ÎÒÏÖÔÚÒª°Ñ id ²»ÊÇ14 µÄËùÓÐ InfoTxt×ֶΠÎı¾ºóÃæ ¶¼¼ÓÉÏ 'aaa'
°´ÏÂÃæÖ´ÐÐÏÂÀ´ Ö»Óбí×îºóÒ»ÐмÓÉÏÁË 'aaa' ......
<table border= "0 " cellspacing= "0 " cellpadding= "0 ">
<BH_CHANNELS ID= "OWNER " CHILDTYPE= "aaa " ......