Query with two sorts in descending order

-1

Is it possible to execute a query by searching for the contract number, sorting by decreasing date and their respective work orders? If yes, can you give me an example for knowledge ??

Query used:

SELECT * FROM field WHERE contrato LIKE '%$buscar%' ORDER BY Data,Num_OS DESC
    
asked by anonymous 01.10.2018 / 12:57

1 answer

-1

Yes, it is possible. You just have to put the fields that you want to sort in the mysql sort command: order by :

SELECT * --campos que deseja retornar
FROM nome_tabela
WHERE num_contrato = @num_contrato --@num_contrato será o contrato a ser pesquisado
ORDER BY data, ordem_servico desc --desc é palavra reservada e indica que a ordenação é decrescente

It's important that you take a look at the link that I put in and study a little about ordering. There is a lot of good material on the net, worth researching!

    
01.10.2018 / 13:05