1
I am making adjustments in a graphics system, basically there is a query in the database to bring values and popular the chart, but when there is no specific record does not return anything from the database and the graph breaks.
I wish that when there was no record at least bring the fields with zero values, it is possible?
Obs.: I use the Mysql. The graphics are in JS, after the query turn it into JSON for the graph consume.
Example:
select nome from clientes
If you have registration and I convert to JSON will look like this:
{nome: fulano, nome: ciclano}
But if there is no record:
{}
And I’d like that at least:
{nome: ""}
But I’d only be interested if it was a bank solution, I don’t know if it’s possible.
This graph is of what language/teconologia? I ask for the fact of doing this treatment on the other side.
– Roknauta
Hello @Douglas is JS
– Lennon S. Bueno
Please post your query, and it might be better to control this in the application itself and not in the database
– Jeferson Almeida
@Jefersonalmeida after the query turn the result into JSON for the chart, but if there is no record there is no JSON for the chart
– Lennon S. Bueno
Then, you can return an empty json qnd n has data to the filter and in the application do a treatment for it stating that n had results
– Jeferson Almeida
@Lennons.Bueno then would be something like this:
se resultado == vazio então mostra mensagem persoanlizada senão mostra resultado
.– Roknauta
So it is that they would like that the graph at least appears something even zeroed, I see as solution when it is empty, simulate a JSON with zeros, the doubt was if the SQL had something on, but it was worth
– Lennon S. Bueno