0
I need to take the lowest value of a column to use it as a condition in where
, but I don’t know how to do that. The column I need is the ordering
, as below:
SELECT p.pro_name, p.id, f.image as foto
FROM #__osrs_properties p
LEFT JOIN (
SELECT image, pro_id
FROM #__osrs_photos
WHERE ordering = "menor ordering"
) f ON f.pro_id = p.id
ORDER BY pro_name DESC
LIMIT 21
The tables are like this:
osrs_properties
id|pro_name
1 | joao
2 | nome
3 | maria
osrs_photos
id|pro_id| image | ordering
1 | 1 | imagem1.jpg | 2
2 | 1 | imagem2.jpg | 1
3 | 2 | imagem3.jpg | 1
I couldn’t understand what you need. Can you explain better?
– Roberto de Campos
What do you expect this
select
returns?– Roberto de Campos
i need it to bring which the smallest Ordering, for example (SELECT MIN(ordergin) FROM #__osrs_photos) then I will use this information where is the WHERE Ordering = "lowest Ordering"
– Leandro Marzullo
I’m not sure if it’s a select within another, or would have another way
– Leandro Marzullo
Okay, but you have two
ordering
minor, edit the question and place a table with the return you need– Roberto de Campos
A
ORDER BY ordering LIMIT 1
doesn’t solve?– Woss
I answered your question, take a look if that’s what you need. if it is not, try to put an example of how you would like the records to appear on the screen, so we understand better and can help you.
– Fernando VR