Concatenation OR, AND, ORDER BY, and RAND () do not work

0

I have the following SQL :

SELECT id,titulo,slug,endereco
FROM empresas
WHERE
(categoria = ".$_GET['id']." OR categoria_2 = ".$_GET['id']."  OR categoria_3 = ".$_GET['id'].") AND (status = '1') ORDER BY chave DESC, RAND()

But it does not sort by the key field and Rand does not work

I try to manipulate the parentheses and then the status = '1' stops working.

How do I make this line work with the structure OR , AND , ORDER BY and RAND() ?

    
asked by anonymous 04.12.2018 / 16:42

0 answers