HSHO
HSHO

Reputation: 525

Creating MySQL Query But its not working and error occurs

I am trying to Create a Query Where i will Select whole Table1 and Filter Table1.DateColumn using Between clause to match ids in Table2.

Because Table1 has dates but table2 does not have.

SELECT * FROM Table1 
WHERE Table1DateColumn 
BETWEEN '2015-03-01' AND LAST_DAY('2016-02-01')

INNER JOIN Table2 
ON Table1.ID's = Table2.ids;

Upvotes: 0

Views: 23

Answers (1)

The Impaler
The Impaler

Reputation: 48770

The sequence of the SQL clauses is incorrect. The correct order of the clauses should be:

SELECT * 
FROM Table1 
INNER JOIN Table2 ON Table1.IDs = Table2.ids
WHERE Table1DateColumn BETWEEN '2015-03-01' AND LAST_DAY('2016-02-01')

Upvotes: 1

Related Questions