0
I am with a query that when ordering it in ASC it Zera a column of my table, but if I sort in DESC displays the values normally.
This is the query:
SELECT
`tab_medicamentos`.`id`, `tab_medicamentos`.`classe_terapeutica`, `tab_medicamentos`.`apresentacao`, `tab_medicamentos`.`produto` as `nome`, `tab_medicamentos`.`pmc_18_perc` as `preco`, `tab_medicamentos`.`img` as `imagens`, `tab_medicamentos`.`margem`, `tab_medicamentos`.`margem_desconto`, `tab_medicamentos`.`restrcao_hospitalar`
FROM
`tab_medicamentos`
WHERE
`classe_terapeutica` LIKE '%M01C0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%L01B0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%N02A0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%N02B0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%N01A2%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%N01B1%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%M01A1%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%M02A0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%R05A0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%A11D4%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%A03D0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%M01A3%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%B01C1%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%M03B0%' ESCAPE '!'
OR `classe_terapeutica` LIKE '%N02C9%' ESCAPE '!'
ORDER BY `pmc_18_perc` ASC
When I put the ORDER BY ASC
he Zera all values of this column 'pmc_18_perc'
, but when I order in DESC
appears the values normally.
What can it be?
Are you sure you’ve wiped them all out or just in the first few records? Why
ORDER BY ASC
will bring the data starting from "minor", zeros, spaces, etc first... may be that the filled data are in the next records, came to look all the result ofselect
?– Ricardo Pontual
did not reset all values, just ordered those with "0".
– Doan Casotti
Try WHERE, pmc_18_perc IS NOT NULL
– Leonardo Pliskieviski
I forgot to mention that because I knew it would be my first chance. I checked at the end of the result, and from the first line to the last the value was reset! I never saw that! I put IS NOT NULL and it hasn’t changed a bit.
– Marlon Souza