PHP PDO Select using date clause not working
My PHP PDO code selects several tables via INNER JOIN relationships.
For instance, the code below works only in PHPMYADMIN.
Via PHP PDO code it doesn't.
sql = `SELECT c.cliente, p.pasta FROM tabpastas p
INNER JOIN tabclientes c
ON p.cliente_tabclientes = c.id
INNER JOIN tabts t
ON t.pasta_tabpastas = p.id
INNER JOIN tabpessoas g
ON t.profissional_tabpessoas = g.id
WHERE p.id IN (SELECT DISTINCT pasta_tabpastas FROM tabts)
AND t.int_status = 2
AND t.data_trabalhada BETWEEN '2020-11-01' AND '2020-11-6'`;
In the Chrome console appears:
<b>Fatal error</b>: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE 1=0' at line 1
Otherwise, if I take the line which use dates to retrieve data from the SQL, it works.
Hence, my problem is to use dates.
My tables are:
Table name: tabts
Fields: id (autoincrement) data_trabalhada (date), pasta_tabpastas (int)
Table name: tabpastas
Fields: id (autoincrement) pasta (int), cliente_tabclientes (int)
Table name: tabclientes
Fields: id (autoincrement),cliente (varchar)
Table name: tabpessoas
Fields: id (autoincrement), pessoa (varchar)
Subject
Written By
Posted
PHP PDO Select using date clause not working
November 04, 2020 05:06PM
November 04, 2020 05:08PM
November 04, 2020 05:57PM
November 05, 2020 05:09AM
November 05, 2020 10:08AM
November 05, 2020 12:11PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.