M
M
Mikhail Gavrilyuk2018-05-02 00:17:03
MySQL
Mikhail Gavrilyuk, 2018-05-02 00:17:03

How to select multiple random posts that should have one or two rows with a specific id?

How to select multiple random posts that should have one or two rows with a specific id ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel K, 2018-05-02
@PavelK

Select * from table where id=14 order by rand() limit 88 - will select a maximum of 88 rows that have an id of 14. But this will be slow, and will slow down as the number of records grows. You can initially generate a random number and use it as the initial shift in limit. Either it’s night, or I didn’t understand completely - at the beginning, talk about a few, then about one or two ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question