ÇóSQLÒ»ÌõÓï¾äµÄ½â¾ö·½·¨
±ÈÈç ÎÒÓÐÒ»¸ö±í bumen
ÀïÃæ ÓÐÒ»¸öÁÐ quanxian
id name quanxian
1 a 001;002;003;
2 b 002;003;
3 c 003;004;
4 d 001;002;003;
ÎÒµÄÒâ˼ÊǰÑquanxianÁÐÖк¬ÓÐ002µÄÊý¾ÝÈ¡³öÀ´£»ÏÔʾÔÚgridviewÉÏ£¿
Çë´óÏÀÃǰïæ£¡
select * from tumen where quanxian like '%002%'
select * from tumen where quanxian like '%002%'
select * from tumen where charindex('002',quanxian) > 0
SQL code:
if object_id('ta') is not null drop table ta
go
create table ta(id int, name varchar(1), quanxian varchar(20))
insert into ta select
1, 'a', '001;002;003;' union all select
2, 'b', '002;003;' union all select
3, 'c', '003;004;' union all select
4, 'd', '001;002;003;'
select * from ta
where charindex(';002;',';'+quanxian)>0
id name quanxian
----------- ---- --------------------
1 a 001;002;003;
2 b 002;003;
4 d 001;002;003;
(3 ÐÐÊÜÓ°Ïì)
SQL code:
select * from tumen where charindex(','+'002'+',',','+quanxian+',') >
Ïà¹ØÎÊ´ð£º
sql table±íÓиöÎı¾ÀàÐ͵Äa×ֶΣ¬´æ´¢µÄÄÚÈÝÈ«²¿ÊÇÊý×Ö£¬ÀýÈç2009001£¬2008578ÕâÑùµÄ¸ñʽ£»b×Ö¶ÎÎı¾ÀàÐÍ£¬´æµÄÒ²ÊÇÊý×ÖÀýÈç 001£¬123
aspÀïÃæ strday=100£¬strb=001
ÎÒÏë¶Á³ö£¬´Óa×ֶεÄÊý×Ö°´´óµ½Ð¡µÄË ......
ÔõôʹÎÒÿ´Î²»ÊǸüÐÂÊý¾Ý¿â
¶øÊǸ²¸ÇÉϴεÄËùÓмÇÂ¼ÄØ£¡
ÒòΪÓÐʱºòʱ¼äÌõ¼þ²»Í¬
SQL code:
select * from hwouttb where
CAST(REPLACE(REPLACE(REPLACE(outdate,'Äê','-' ),'ÔÂ','-'),'ÈÕ','') AS ......
SQL code:
declare @cnt int
select @cnt=count(1) from TableTest
if(@cnt==0)
insert into TableTest values(1,'abc')
¶ÔÓÚÕâÑùµÄÒ»¶Îsql²¢·¢Ö´ÐÐʱ,Ó¦¸ÃÓпÉÄܲåÈëÖØ¸´¼Ç¼
²»ÖªµÀ´ó¼ÒÊÇÔõô· ......
µã»÷¡°·þÎñ¹ÜÀíÆ÷¡±£¬µã»÷¡°¿ªÊ¼/¼ÌÐø¡±£¬×ÜÊÇÏÔʾ¡°ÓÉÓڵǼʧ°Ü¶øÆô¶¯·þÎñ¡±£¬È»ºóÔٴγö´í£¬²»Äܹ»½øÈ룬Ҳ²»Äܹ»²é¿´ÊôÐÔ£¬ÇëÎÊ´ó¼Ò¸ÃÔõô°ì£¿
ÎÒÊDzſªÊ¼Ñ§Ï°Êý¾Ý¿â£¬ÇëÎÊ´ó¼ÒÓÐûÓÐʲôºÃһЩµÄ½¨Òé»òÕ ......