select categories_id,parent_id,categories_name 
from categories a , categories_desction b 
where a.categories_id = b.categories_id

解决方案 »

  1.   

    select a.categories_id,a.parent_id,b.categories_name 
    from categories a , categories_desction b 
    where a.categories_id = b.categories_id
      

  2.   

    declare @a table(categories_id int,parent_id int)
    insert @a select 1, 0
    union all select 2 ,0
    union all select 3 ,0
    union all select 4 ,1
    union all select 5 ,1
    union all select 6 ,1
    union all select 7 ,2
    union all select 8 ,2
    union all select 9 ,2
    union all select 10, 3
    union all select 11 ,3
    union all select 12 ,3
    declare @b table(categories_id int, categories_name varchar(10))
    insert @b select 1, 'A'
    union all select 2 ,'B'
    union all select 3 ,'C'
    union all select 4 ,'Aa'
    union all select 5 ,'Ab'
    union all select 6 ,'Ac'
    union all select 7 ,'Ba'
    union all select 8 ,'Bb'
    union all select 9 ,'Bc'
    union all select 10, 'Ca'
    union all select 11,'Cb'
    union all select 12,'Cc'select a.categories_id,parent_id,categories_name from @a a inner join @b b on a.categories_id=b.categories_id order by categories_name