select FirstName, LastName, City, State
from Person as p
left join Address as a
on p.PersonId = a.PersonId;
City和State位于Address表中,利用左连接将表连接起来!
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {
//创建一个头结点
ListNode head=new ListNode(0);
head.next=list1;
ListNode temp1=head,temp2=head;
//第一个指针迭代到索引为a-1处
for(int i=1;i<=a;i++){
temp1=temp1.next;
}
//第二个指针迭代到索引为b+1处
for(int i=1;i<=b+2;i++){
temp2=temp2.next;
}
//被插入的链表指针移到末尾
ListNode list3=list2;
while(list3.next!=null){
list3=list3.next;
}
//插入
temp1.next=list2;
list3.next=temp2;
return head.next;
}
}