First of all, let me explain that I was looking for at least an hour for anything related to this MUCH keyword in MySQL. The problem is that any search engine that I use to search for information about it matches the word "ON" in the most trivial and unrelated results. I was also unlucky in looking at the MySQL documentation.
I see when used with an INNER JOIN as a condition, but I have no idea what it does. An example of use is
SELECT t1.name, t2.salary
FROM employee AS t1 INNER JOIN info AS t2 ON t1.name = t2.name;
I know that the differences between "WHERE" and "HAVING" are the difference between filtering strings and filtering groups, respectively.
I can’t imagine which filters are “ON”.
I figured this might be needed for filtering when using an INNER JOIN, but I used to use WHERE in INNER JOIN cases, for example:
SELECT g.id, g.name, g.date_created, g.date_updated, g.created_by,
c.fullname AS creator_name, g.updated_by, u.fullname AS updater_name,
COUNT(i.id) as image_count
FROM gallery_groups g INNER JOIN
users c INNER JOIN
users u INNER JOIN
gallery_images i
WHERE g.created_by=c.id AND g.updated_by=u.id AND i.group=g.id
GROUP BY g.name
ORDER BY g.date_updated DESC, g.name
Any information and / or examples would be appreciated!
source
share