Skip to content

Instantly share code, notes, and snippets.

@joynal
Last active December 29, 2016 08:06
Show Gist options
  • Save joynal/a3238bcd2214913f2ac38de2e07fc95d to your computer and use it in GitHub Desktop.
Save joynal/a3238bcd2214913f2ac38de2e07fc95d to your computer and use it in GitHub Desktop.
SELECT
a2, b2, c2
FROM
A
INNER JOIN
B ON B.a_id = A.id AND B.b1 = "Y"
INNER JOIN
C ON C.b_id = B.id AND C.c1 = "Z"
WHERE A.a1 = 'X';
// Experimendted on sample database [http://www.mysqltutorial.org/download/2]
SELECT
jobTitle, customerName, orderNumber, orderDate
FROM
employees E
INNER JOIN
customers C ON E.employeeNumber = C.salesRepEmployeeNumber AND C.customerName = "Technics Stores Inc."
INNER JOIN
orders O ON C.customerNumber = O.customerNumber
WHERE E.jobTitle = "Sales Rep";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment