本文已参与「新人创作礼」活动,一起开启掘金创作之路。
select 表1.字段1,表1.字段2,表1.字段3 case when 表1.字段1=表1.字段1
then (select 需要获取的值 from 表2 where 表2.字段=表1.字段1)
else '无' END as c,case when 表1.字段2=字段2
then (select 需要获取的值 from 表2 where 表2.字段=字段2)
else '无' END as d ,
case when 表1.字段3=表1.字段3
then (select 需要获取的值 from 表2 where 表2.字段=表1.字段3)
else '无' END as a
from 表1 a where 表1.字段=XXX