求一条sql 语句
select UnitID,UnitName from UnitMessage where UnitID in (select Uid from Qyzrrfp)
我想查UnitMessage 表里的数据,条件是UnitID在Qyzrrfp表里,其中UnitID 是int类型,Uid 是nvarchar 类型
------解决方案--------------------如果Qyzrrfp表的Uid是以逗号隔开的UnitID,试试以下语句
select a.UnitID,a.UnitName
from UnitMessage a
join Qyzrrfp b on charindex(','+ltrim(a.UnitID)+',',','+b.Uid+',')>0