J
J
JayDeeZz2018-03-19 12:43:59
PHP
JayDeeZz, 2018-03-19 12:43:59

How to combine 2 sql queries?

Have a request

SET @n = 0;
SELECT (@n := @n + 1) AS rank, id, votes, game
FROM servers ORDER BY votes DESC;

5aaf86303e3da750380505.png
I need to put forward a request to this after this request to display a specific line by id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman PHP, 2018-03-19
Tag

wrap in another select

SELECT *
FROM (<ваш селект>) AS a
WHERE a.rank = 1

but if you need the third place, for example, in the votes field, then it's easier to do this
SELECT id, votes, game
FROM servers 
ORDER BY votes DESC
LIMIT 2,1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question