Home > Net >  Creating MySQL Query But its not working and error occurs
Creating MySQL Query But its not working and error occurs

Time:12-10

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;

CodePudding user response:

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')
  • Related