主表字段:编号、姓名、学生类型
其中一条记录:001、张三、011从表字段:编号、学生类型
其中一条记录:011、本科怎么查询出这样格式的记录:001、张三、本科就是主表存的学生类型的编号转换成具体的类型。

解决方案 »

  1.   

    select 主表.编号,主表.姓名,从表.学生类型 from 主表,从表
    where 主表.编号 = 从表.编号
    --and ...
      

  2.   

    select stuNo, stuName, stuTypeName from student, studentType
    where student.stuTypeNo = studentType.stuTypeNo
    and student.stuNo = '001';
      

  3.   

    create table student
    (
      stuNo     char(3) not null,
      stuName   varchar(32),
      stuTypeNo char(3),
    primary key (stuNo)
    );create table studentType
    (
      stuTypeNo   char(3) not null,
      stuTypeName varchar(32),
    primary key (stuTypeNo)
    );
      

  4.   

    SELECT [a].[编号],[a].[姓名],[b].[学生类型] FROM [主表] a , [从表] b WHERE [a].[编号] = [b].[编号]
      

  5.   

    select 主表.编号,主表.姓名,从表.学生类型 where 主表.编号=从表.编号
    试一试,应该可以的
      

  6.   

    select t1.编号,t1.姓名,t2.学生类型 from 主表 as t1 inner join 从表 as t2 on t2.编号 = t1.编号