S
S
Sergey Valitov2015-10-07 18:23:44
PHP
Sergey Valitov, 2015-10-07 18:23:44

How can I sort the fields according to my rules?

Hello! There is a sign. I need to select all the values ​​​​from the table according to the one defined through Where, and if the values ​​\u200b\u200bare less than 24, then add random values ​​\u200b\u200bto make it 24 in the end. For example, we are looking for the city in the table, and we are given 15 points with Moscow, the remaining 9 points are given randomly from the table.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Volintsev, 2015-10-07
@copist

Make two requests and connect in PHP. It will be easier.

M
Max, 2015-10-07
@MaxDukov

clumsily - do SELECT with UNION in advance - and choose LIMIT 24. Extremely inefficient.
a little less clumsily - write a storage that itself will "get" to 24 only if it is not enough. More effective.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question