#获取两个表中字段匹配关系的记录 select a.user_code, a.user_name, b.user_code, b.user_name from app_users a inner join app_users_bak b on a.user_code = b.user_code #获取左表所有记录,即使右表没有对应匹配的记录 select a.user_code, a.user_name, b.user_code, b.user_name from app_users a left join app_users_bak b on a.user_code = b.user_code; #获取右表所有记录,即使左表没有对应匹配的记录 select a.user_code, a.user_name, b.user_code, b.user_name from app_users a right join app_users_bak b on a.user_code = b.user_code