Created
August 14, 2014 21:04
-
-
Save betweenbrain/b0027305656e44fe882e to your computer and use it in GitHub Desktop.
Simple MySQL Join with Last Month Where Clause
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
table1.id, | |
table1.firstName, | |
table1.lastName, | |
table2.sales, | |
table2.date | |
FROM `table1` | |
LEFT JOIN `table2` ON table1.firstName = table2.firstName | |
WHERE MONTH(table2.date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment