JOIN ON in SQL can only specify one matching condition. If you need to match multiple conditions, you can use the WHERE clause. Alternatives include: Subquery UNION ALLCASE Expression EXISTS
JOIN ON condition in SQL
The JOIN ON statement in SQL joins two or more tables and uses one or more conditions to match rows. However, JOIN ON can only specify one condition.
If you need to use multiple conditions to match rows, you can use the WHERE clause:
<code class="sql">SELECT * FROM table1 JOIN table2 ON table1.id = table2.id WHERE table1.name = table2.name;</code>
The above query uses JOIN ON to match table1
and # Rows with the same ID in ##table2, and then use the WHERE clause to further filter the rows and select only rows with the same name.
The above is the detailed content of Can there be two conditions for join on in sql?. For more information, please follow other related articles on the PHP Chinese website!