update b set childarticlecount=(
select count(*) from article where article.regionkey like ''% b.id %'') from region b这句话总是运行时提示对数据类型而言运算符无效。运算符为 modulo,类型为 nvarchar。应该怎么写啊?
select count(*) from article where article.regionkey like ''% b.id %'') from region b这句话总是运行时提示对数据类型而言运算符无效。运算符为 modulo,类型为 nvarchar。应该怎么写啊?
select count(*) from article where charindex(b.id,regionkey )>0) from region b
select count(*) from article where article.regionkey like '% b.id %') from region b
update b set childarticlecount=(
select count(*)
from article
where charindex(b.id,regionkey) > 0)
region b
update b set childarticlecount=(
select count(*)
from article
where charindex(b.id,regionkey) > 0)
from region b
(
regionkey nvarchar(100)
)
insert article
select '1 a 1' union all
select '2 a 2'
select '1 9 1' union all
select '2 9 2'create table region
(
childarticlecount int,
id int
)
insert region
select null, 9--select * from article
--select * from regionupdate b
set childarticlecount = (select count(*) from article where regionkey like '% ' + cast(b.id as varchar(10)) + ' %')
from region b/*
childarticlecount id
2 9
*/
===》
article.regionkey like '%'+rtrim(b.id)+'%'