高分求购一句sql语句

lonelybird818 2006-01-06 05:10:03
现在有三个表:
table1 字段:
libplace|description
值:
1|文科图书馆
2|理科图书馆

table2 字段:
gateno|libplace
值:
01|1
02|1
03|2


table3 字段:
name|gateno
值:
张三|01
李四|02
王五|03

要求:
在table3中,查询name,条件:文科图书馆
(sql语句,非存储过程)
...全文
80 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
brooks105 2006-01-06
  • 打赏
  • 举报
回复
create table table1
(libplace int,description char(20))
insert table1
select 1,'文科图书馆'
union all
select 2,'理科图书馆'

create table table2
(gateno char(5),libplace int)
insert table2
select '01',1
union all
select '02',1
union all
select '03',2


create table table3
(name char(10),gateno char(5))
insert table3
select '张三','01'
union all
select '李四','02'
union all
select '王五','03'


select a.name from table3 a
join table2 b on a.gateno=b.gateno
join table1 c on b.libplace=c.libplace
where c.description = '文科图书馆'

name
----------
张三
李四

(所影响的行数为 2 行)
子陌红尘 2006-01-06
  • 打赏
  • 举报
回复
select c.name from table1 a inner join table2 b on a.libplace=b.libplace inner join table3 c on b.gateno=c.gateno where a.description='文科图书馆'
pbsql 2006-01-06
  • 打赏
  • 举报
回复
select table3.name
from table1,table2,table3
where table1.libplace=table2.libplace
and table2.gateno=table3.gateno
and table1.[description]='文科图书馆'

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧