Answer the question
In order to leave comments, you need to log in
Explain why my SQL query is what?
But in plain language, the query displays the servers according to the following criteria:
1) Have a VIP (is_vip = 1) and connected services
2) Have no VIP, but have connected services
3) Have a VIP, but do not have connected services
4) Have no VIP, do not have connected services
Each service has its own priority, according to which sorting is carried out, so that services such as "SUPIR PUPIR SERVICE" bring all servers to the first places, that it was connected and the reference went exactly to a certain flag - priority (it is sorted everywhere ).
There are 4 levels of selections, each one is needed for something:
1. Selection of all records with a 'top' increment - in order to determine what position the record is in
2. The second is just to set the @c variable, which will then go to top at select level 1 - this had to be done this way, because PDO apparently does not support SET var := 0, etc.
3. The third level is simply needed in order to be able to combine the results with sorting, because UNION does not work on selections with ORDER BY
4. The fourth level simply displays the data you need + JOIN
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question