Mysql 要使用多个条件联接多个表吗

Mysql 要使用多个条件联接多个表吗,mysql,jdbc,inner-join,Mysql,Jdbc,Inner Join,下面是我的问题 SELECT salary.id, employee.emp_id, employee.emp_name, department.dept_name, designation.desig_name, salary.basic, salary.house_rent + salary.conveyance + salary.medical + salary.dearness + salary.othe

下面是我的问题

SELECT salary.id,
       employee.emp_id,
       employee.emp_name,
       department.dept_name,
       designation.desig_name,
       salary.basic,
       salary.house_rent + salary.conveyance + salary.medical + salary.dearness + salary.others_allowances AS allowances,
       salary.income_tax + salary.pro_tax + salary.emp_state_insu + salary.others_deductions AS deductions,
       Sum(attendance.attendance = 'Absent') * salary.absence_fine AS fine,
       Monthname(attendance.date) AS month,
       salary.month AS monYear
  FROM employee
       INNER JOIN attendance ON employee.emp_id = attendance.emp_id
       INNER JOIN department ON employee.dept_id = department.dept_id
       INNER JOIN designation ON employee.desig_id = designation.desig_id
       INNER JOIN salary ON designation.desig_id = salary.desig_id
  GROUP BY salary.id,
           employee.emp_id,
           Monthname(attendance.date)  
我的输出是:


请帮我解决这个问题

您需要一个列来将出勤率与工资联系起来,假设每个表上都有一个名为month_id的列,那么您可以在最后一个内部联接中添加一个条件。 大概是这样的:

INNER JOIN salary ON designation.desig_id = salary.desig_id and attendace.monthId = salary.month_id

也许你可以描述一下这个问题,因为我不相信从你使用的图像中可以清楚地看出,你注意到你使用了两个不同的列来查看mont。出勤率。每月日期。姓名功能和工资。每月/年。因此,您有两种情况:1-列存储不同的日期2-您的联接有问题完全指定的聚合/组查询在既不按分组也不聚合的字段中给出不确定(半随机)结果。考勤表中的月列se和薪资表中的年月列se。。我的查询通过从所有工资记录中扣除罚款来生成输出,即使这些记录来自不同的月份。。。它应该从2018年12月的月平均值中扣除12月的氘罚款。但从2018年10月的所有值中扣除后,我能改进我的查询或表关系吗