A
A
anna_makeenko2020-07-30 14:10:32
Mathematics
anna_makeenko, 2020-07-30 14:10:32

How to determine the % of the distance traveled?

For example, there are 100500 posts on the site. A script is launched that finds the desired posts using a regular expression (MySQL). Let's say that the script goes through 500 posts in one run, writes down the post ID at the end of its work, and continues to work the next time it is run.

How to determine the number of passed news in% knowing the ID of the post where the script stopped?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twobomb, 2020-07-30
@anna_makeenko

SELECT (SELECT COUNT(*) FROM posts WHERE id <= $lact_checked_id)/(SELECT COUNT(*) FROM posts)*100 as percent

I
Ivan Shumov, 2020-07-30
@inoise

Save the number of posts passed and the number of all posts. To divide one into another, I think, it is not necessary to learn)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question