表一:
编号
驾照类型:
准驾车型:
1 A1 大型客   
2 A2 牵引车  
3 A3 城市公交车
4 B1 中型客车
5 B2 大型货车
.......
.......
.......
表二:(驾照不同种类所能开的汽车类型(A1也可以开(A3,B1,B2,B3,C1....)))
编号:
驾照类型:
驾照类型:
1 A1 A3
2 A1 B1
3 A1 B2
4 B1 B2
5 B1 B3
......
....
.....
....要求不用视图
直接用SQL语句查询出所有驾照能开的所有车型               

解决方案 »

  1.   

    create proc busType
    declare @jzType varchar(5)
    declare @mytable Table
    asselect 准驾车型 from table1 where 驾照类型 in
    (select 驾照类型2 from table2 where 驾照类型1=@jzType) into @mytable
    这种方法是你提供一种驾照类型,输出你所有的车型
      

  2.   

    table 输入错误了应该是
    select some into @table from table格式
      

  3.   

    select 驾照类型,准驾车型 from table1 union
    select c.驾照类型,d.准驾车型 from (select a.驾照类型2,b.驾照类型 from table2 a,table1 b where a.驾照类型1=b.驾照类型) c,table1 d where  d.驾照类型=c.驾照类型2)