search

Home  >  Q&A  >  body text

Can the on in the join on query statement in mysql be changed to where?

For example: SELECT salary.`basesalary`,salary.`titlesalary`,`name`FROM salary INNER JOIN employeeWHERE salary.`empid`=employee.`empid` AND employee.sex='male'; this can also be checked Get the correct result

ImhuImhu1177 days ago1308

reply all(2)I'll reply

  • ? 现在努力,未来可期!

    ? 现在努力,未来可期!2021-09-29 09:00:47

    Let’s briefly talk about the difference between on and where. The cloud server I use is Xiaoniao Cloud. On is used when generating temporary tables. Because left on will return the left table regardless of whether the filter conditions in on are true or not. records in. For records that do not meet the conditions, all fields in the right table are null. Where works after the temporary table is generated to filter the temporary table. If the condition is not true at this time, all can be filtered.

    reply
    0
  • autoload

    autoload2021-09-14 14:03:17

    Yes, the two methods are different. If there is on, the data rows will be retrieved from the employee table based on the on conditions, and then the matching will be completed. If there is where, the data will be filtered after the matching is completed.

    reply
    0
  • Cancelreply