1
I’m trying to put two tables together 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’t find any solution.
So I tried the following on 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 inserted in tables
Table inquiry
Response table
Do you have the structure of the tables? If you can post them it is better to help.
– Clayton Tosatti
I’ve already altered Clayton!
– Ana
Hi Ana! I’m not sure what you’re looking for, Group of questions by rating, along with the whole inquiry and question? What columns do you want exactly? the missing alias is due to Count’s select, but I need to figure out what you want to solve ;)
– Ana Teixeira
Good morning Ana, yes what I intend is to join both tables, return all information, between two dates. The query in phpMyAdmin already works, it returns what I intend, but in php appears the following error
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in
– Ana