关联查询?
如二个表:
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