首页 新闻 搜索 专区 学院

sqlserver in 子查询问题

0
悬赏园豆:10 [待解决问题]

create table db_user(id int primary key,name nvarchar(256));
go

insert into db_user select 1,'test_1' union all
select 2,'test_2' union all
select 3,'test_3' ;
go

create table db_score(score_id int, user_id varchar(256),score varchar(256));
go
insert into db_score select 1, '1,2','90' union all
select 2,'3','80'
go

查询报错:

select id,name from db_user where id in(select user_id from db_score where score_id =1)

乐上的主页 乐上 | 初学一级 | 园豆:8
提问于:2015-01-15 16:57
< >
分享
所有回答(2)
1

id int

user_id varchar(256)

爱编程的大叔 | 园豆:30748 (高人七级) | 2015-01-15 17:02
0

select id,name from db_user where convert(nvarchar(256),id) in(select user_id from db_score where score_id =1)

指尖流淌 | 园豆:340 (菜鸟二级) | 2015-01-17 15:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册