T
T
Tolic12021-05-08 11:23:36
SQL
Tolic1, 2021-05-08 11:23:36

How can I make a bonus every 24 hours?

Tell me how can I implement a bonus once every 24 hours? I realized that I need to record the time after pressing the button, and then what should I do? And tell me how to update the column through another variable

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2018-10-23
@adrenalinruslan

Depends on the SQL dialect. For MySQL something like this:

DELETE `h1`.*
  FROM `history` AS `h1`
  LEFT JOIN (
    SELECT MIN(`id`) AS `min_id`
      FROM `history`
      GROUP BY `g_id`
  ) AS `h2` ON `h2`.`min_id` = `h1`.`id`
  WHERE `h2`.`min_id` IS NULL

V
Vindicar, 2021-05-08
@Tolic1

You fix the time of pressing the button.
You select from basis value of the previous time on id request SELECT.
If there is no value, the person writes for the first time, we enter the time value and user id into the database with an INSERT query . We send a message about the bonus.
If there is a value, and the difference between it and the current time is more than 24 hours, a person can receive a bonus. We update the value in the database with an UPDATE request and send a message about the bonus.
If there is a value, and the difference is less than 24 hours, we send a message with the time remaining until the next bonus.

Y
Yupiter7575, 2021-05-08
@yupiter7575

Man: wrote to the bot
bot: Hey DB here people with this id wrote. Do you have it inside?
DB: There is no such id
bot: Well then, write it down, and also write down the time it is now
DB: success
Person2: wrote to the bot
bot: Hey DB, there is a person with this id wrote. Do you have it inside?
BD: Yes, there is one. The last time 25 hours ago the
bot wrote: Cool, see you soon.
bot *to person2*: Bro, well done for writing again, you have a present

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question