There is a table with the date in the format Ymd H:i:s (VARCHAR) "add_date" The id users who made the entry in this table is "adder_id" .

I try to count through COUNT() number of unique "adder_id" in the interval minus one hour.

 $current_date = date("Ymd H:i:s"); $current_date_hour = date( 'Ymd H:i:s', time()+(-1*60*60) ); 

I try and so and so. And through GROUP BY adder_id .

For example, initially tried to get the desired value through:

 SELECT COUNT(*) FROM `note_block` WHERE `add_date` < '".$current_date."' AND `add_date` > '".$current_date_hour."' GROUP BY `adder_id` 

or

 SELECT COUNT(*) FROM `note_block` WHERE `add_date` > '".$current_date_hour."' GROUP BY `adder_id` 

But the meter displays anything but the expected number. = (

1 answer 1

Casket opened just ...

SELECT COUNT (DISTINCT adder_id) FROM note_block WHERE add_date > '". $ Current_date_hour."'

  • one
    Read about WHERE add_date > add_date + INTERVAL 1 HOUR - Opalosolo
  • 2
    @ ua6xh Das ist fantastisch! WHERE add_date> add_date + INTERVAL 1 HOUR Why does it seem to me that this condition is always "false"? (Being bigger than myself, increased by an hour. However) - alexlz