T
T
thisall2021-12-08 14:33:09
SQL
thisall, 2021-12-08 14:33:09

How can I shorten the request?

SELECT type, time_from, time_to 
FROM manager_orders 
WHERE aptid = 262707 
  AND cancelled_at is null 
  AND ('2021-04-26 11:00:00' 
       BETWEEN time_from - INTERVAL 30 Minute 
           AND time_to + INTERVAL 30 Minute
    OR '2021-04-26 11:00:00'
       BETWEEN time_from - INTERVAL 30 Minute
           AND time_to + INTERVAL 60 Minute
  )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-12-08
@thisall

SELECT type, time_from, time_to 
FROM manager_orders 
WHERE aptid = 262707 
  AND cancelled_at is null 
  AND (
  time_from 	<= '2021-12-07 16:12:00' + INTERVAL 30 Minute AND 
  time_to 	>= '2021-12-07 16:12:00' - INTERVAL 60 Minute 
  );

MariaDB fiddle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question