我很难做到以下几点:
select a.FirstName, a.LastName, v.District from AddTbl a order by Firstname inner join (select distinct LastName from ValTbl v where a.LastName = v.LastName)
我想加入ValTbl,但仅适用于不同的值。
试试这个:
select distinct a.FirstName, a.LastName, v.District from AddTbl a inner join ValTbl v on a.LastName = v.LastName order by a.FirstName;
或这样做(它的作用相同,但语法不同):
select distinct a.FirstName, a.LastName, v.District from AddTbl a, ValTbl v where a.LastName = v.LastName order by a.FirstName;