-2

here Iam trying to fetch two table data based on one column 'createdon' and my statement is like below

"SELECT * FROM table1 INNER JOIN table2 ON table1.createdon = table2.createdon WHERE table1.createdon AND table2.createdon BETWEEN '$fromdate' AND '$todate' ORDER BY id"

would anyone correct me please, if Iam wrong

Thanks you......

  • 1
    What does this have to do with `mysqli_multi_query()`? That's for executing two queries in one call, not for querying two tables. – Barmar May 21 '20 at 20:43

1 Answers1

-1

you shouldn't say table1.createdon AND table2.createdon. You only need to test one of them, since the ON condition requires both rows to have the same createdon value.

"SELECT * 
FROM table1 
INNER JOIN table2 ON table1.createdon = table2.createdon 
WHERE table1.createdon BETWEEN '$fromdate' AND '$todate'
ORDER BY id"
Barmar
  • 741,623
  • 53
  • 500
  • 612