0
I need to select the products with the value below 300 reais in which column situacao
be equal to 2
:
Example: in the shopping table I have 8 products registered:
1 sapato valor 25 situacao 1
2 calça valor 50 situacao 2
3 meia valor 60 situacao 2
4 sandália valor 70 situacao 1
5 bicicleta valor 120 situacao 2
6 pc core 2 duo valor 250 situacao 2
7 notebook valor 500 situacao 2
8 ipad 8 gb valor 600 situacao 2
I tried to do it like this, but it didn’t work:
$query = mysql_query("SELECT valor, MAX($valor) FROM ofertas WHERE situacao = '2'") or print (mysql_error());
$query = mysql_query("SELECT valor,FROM ofertas WHERE MAX($valor) AND situacao = '2'") or print (mysql_error());
Being that I need it to be done in the format above or as simple as possible.
Try this query:
SELECT * FROM ofertas WHERE situacao=2 AND valor < 300 ORDER BY valor ASC
that is, selects all values below 300 whose situation is equal to "2" and sorts by the column "value".– Filipe Moraes
Be careful with your titles, because yours does not reflect the content of the question, because you do not want to select the maximum value, but products below a value
– Mateus
Hello La Souza. See how to ask a good question, so it will be easier to help you.
– Filipe Moraes
In the last example in $query = mysql_query("SELECT value,FROM offers WHERE MAX($value) AND situacao = '2'") or print (mysql_error());, is running comma in value, from?
– Renato Junior
This was the wrong way to do it, which I posted just to show how I was doing it wrong. Thank you.
– La Souza