表 t id ls(varchar) ---------------------------- 1 1,3 2 2,4 什么意思?1 1,3表示什么?
表 tt 没有对应的表来保存1,2等对应的type吗?难道要写死?
没有 存 对应的 type ~!
id = int ls = varchar
-- 问题2: select id, (select id from t where charindex(','+ltrim(d.id)+',', ','+ls+',')>0) type, name from d
--1. select id, [type]=case type when 1 then '一类' when 2 then '甲等' end , name from tt --2. select d.id,[type]=t.id,d.name from t join d on charindex(d.id,t.ls)>0
id ls(varchar)
----------------------------
1 1,3
2 2,4
什么意思?1 1,3表示什么?
id = int
ls = varchar
-- 问题2:
select id,
(select id from t where charindex(','+ltrim(d.id)+',', ','+ls+',')>0) type,
name
from d
select
id,
[type]=case type when 1 then '一类' when 2 then '甲等' end ,
name
from tt --2.
select d.id,[type]=t.id,d.name
from t join d on charindex(d.id,t.ls)>0