I have a db with 6 columns: Taarij, Mispar ,Tiltan, Ale, Yaalom and Lev.
I have a query that brings me the 50 last results ordered by Mispar, that works.
select * from Hagrala order by Mispar desc limit 0,50
I want from that query result to find some data.
For example I want to find the value of the field Mispar where Ale = 7 the first time.
What I mean that 7 can and will appear several times in the column called Ale, but I am looking in which Mispar is the highest.
If in a row Mispar = 30765 and Ale = 7 and in another row Mispar = 30755 and Ale=7 also I want to receive only 30765.
Advertisement
Answer
Just use order by and limit:
select * from Hagrala where Ale = 7 order by Mispar desc limit 1;