Left join with condition

后端 未结 6 1014
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 21:17

Suppose I have these tables

create table bug (
    id int primary key, 
    name varchar(20)
)
create table blocking (
    pk int primary key,
    id int, 
          


        
6条回答
  •  [愿得一人]
    2020-12-29 21:53

    make sure the inner query only returns one row. You may have to add a top 1 on it if it returns more than one.

    select 
    t1.id, t1.name,
    (select  b.name from #blocking b where b.id=t1.id and b.name='qa bug')
    from #bug t1 
    

提交回复
热议问题