Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个表,其中包含列“name”“lname”“val”,我希望它们的联合,以便“name”和“lname”是唯一的,第一个表覆盖第二个表的行。Union distinct 看起来像我想要的,但我不能让它只检查前两行。
(select a.name, a.lname, a.val from a) union (select b.name, b.lname, b.val from b left join a using(name, lname) where a.name is null)