首頁  >  文章  >  資料庫  >  sqlserver in 子查询问题

sqlserver in 子查询问题

WBOY
WBOY原創
2016-06-07 15:25:231104瀏覽

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))

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)

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn