-2
When I send the Query:
SELECT * FROM tabela WHERE id_cliente = '$id_cliente' ORDER BY ano DESC
Duplicated values are returned because there are duplicate values in the table. But I want to return only once each year contained in the table.
Failed to submit query’s below:
SELECT * FROM tabela WHERE id_cliente = '$id_cliente' GROUP BY ano ORDER BY ano DESC
SELECT * FROM tabela WHERE id_cliente = '$id_cliente' ORDER BY ano DESC GROUP BY ano
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in [...]
Table structure: here
Usa distinct... SELECT DISTINCT * FROM table WHERE id_client = '$id_client' ORDER BY year DESC
– Thiago Araújo
@Thiagoaraújo continued the same thing, I will edit the question and with the attachment of the database!
– Mustache Web
For the mistake you’re making, it’s not in your
query
, your firstquery
is correct. Try to run it onPHPMyAdmin
directly. Also put all your codephp
to analyze.– Roberto de Campos
@Robertofagundes even in Phpmyadmin continued to bring the results with the doubled year
– Mustache Web
Take a print of
query
which is running and the result in Phpmyadmin– Roberto de Campos
http://imgur.com/zCdTuhC
– Mustache Web
Question, do you want to bring only one user record? Or do you want to bring every year of the user without repeating?
– Roberto de Campos
every year of the user without repeating
– Mustache Web
https://answall.com/questions/28184/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in
– Bacco
SELECT id, id_client, mes, status,ano FROM programacao_cliente_mes WHERE id_client = 2 GROUP BY mes, ano ORDER BY ano DESC
– Sr. André Baill