我想根据id将a表和b表进行合并,其中出账和入账是不同的字段
select a.部门ID,a.出账,b.入账 from table1 a inner join table 2 on a.部门ID = b.部门ID;
join 两个表中不同的列用不同的别名。不存在的默认是null,这样就可以了