基本上我有2个表1或2,如下图所示。我想联合这两个表,但值列应该只在第一个条目中反映一次。
我有关于SQL的基本知识,但请指导我如何按照上面提到的标准获得所需的输出。
你可以用left join做到这一点:
left join
select t2.*, t1.value from table2 t2 left join table1 t1 on t1.code = t2.code and t2.type = 'A';