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()
?