I am trying to join two tables questionario
and resposta
and select from the table questionario
two dates, this was the code I tried in php:
$verificar=mysqli_query($link,"SELECT questionario.*, resposta.* from questionario
JOIN resposta on questionario.pergunta_id=resposta.pergunta_id,
(select COUNT(pergunta_id) as total, classificacao from questionario
where data BETWEEN '".$_POST["datainicial"]."' AND '".$_POST["datafinal"]."'
group by classificacao");
while ($linha = mysqli_fetch_assoc($verificar)) {...}
But it returns this error:
Warning: mysqli_fetch_assoc () expects parameter 1 to be mysqli_result, boolean given
I've reviewed the internet, and I can not find a solution.
So I tried the following in phpMyAdmin:
SELECT questionario.*, resposta.* from questionario
JOIN resposta on questionario.pergunta_id=resposta.pergunta_id,
(select COUNT(pergunta_id) AS total, classificacao from questionario where data
BETWEEN '2018/06/07' AND '2018/06/08' GROUP by classificacao)
As expected the query did not work, it returns this error
Each derived table must have its own alias ...
Here is the structure of the tables
Examples of some data entered in the tables
Home
Questionnaire table