How To Write an Inner Join with the WHERE Clause

Q

How To Write an Inner Join with the WHERE Clause? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries

✍: FYIcenter.com

A

If you don't want to use the INNER JOIN ... ON clause to write an inner join, you can put the join condition in the WHERE clause as shown in the following query example:

mysql> SELECT l.id, l.url, r.comment 
   FROM fyi_links l, fyi_rates r WHERE l.id = r.id;
+-----+-------------------+-----------+
| id  | url               | comment   |
+-----+-------------------+-----------+
| 101 | dev.fyicenter.com | The best  |
| 102 | dba.fyicenter.com | Well done |
| 103 | sqa.fyicenter.com | Thumbs up |
+-----+-------------------+-----------+
3 rows in set (0.00 sec)

2007-05-11, 5124👍, 0💬