首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关联查询?解决方法

2013-10-21 
关联查询?如二个表:Student字段:idname techer(外键)Techer字段:id(主键)name用Techer的id找出某一老师nam

关联查询?
如二个表:
Student字段:
id
name 
techer(外键)


Techer字段:
id(主键)
name

用Techer的id找出某一老师name和所负责学生name

[解决办法]
本帖最后由 bdmh 于 2013-03-14 11:18:04 编辑 select A.Name as teachername,B.Name as studentname from teacher A inner join student B on A.id=B.id where A.id=xxxxx
[解决办法]
select 
stu.name as stuname,
tea.name as teaname
from teacher as tea
inner join student as stu 
on tea.id = stu.techer
where tea.id = @id
[解决办法]

select A.Name as teachername,B.Name as studentname from teacher A,student B where A.id=B.id andA.id=xxxxx

[解决办法]
select
Student.name
Teacher.name
from Teacher,Student
where 
Teacher.id=Student.teacher
and
Teacher.id=***

热点排行