T
T
TechNOIR2018-05-30 10:05:25
SQL
TechNOIR, 2018-05-30 10:05:25

SQL. How to request data between two dates in such a case?

Good afternoon.
There is a query with LEFT OUTER JOIN

SELECT u.event_id, u.event_name, u.start_date, u.end_date, u.serv_id, d.name, c.client_nm as cli FROM tevents u LEFT OUTER JOIN doctors d ON u.`type` = d.id LEFT OUTER JOIN clients c ON u.`combo_select` = c.id

How else can I insert a selection by date range here? ..
WHERE u.start_date between "2018-05-23 08:50:00" and "2018-05-23 08:50:00"

thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan., 2018-05-30
@TechNOIR

So you have a tevents table with an alias u always returned in full, so just add your condition code to the query, it doesn’t matter which join is left or inner in this case.

SELECT u.event_id, 
       u.event_name, 
       u.start_date,
       u.end_date,
       u.serv_id, 
       d.name, 
       c.client_nm as cli 
  FROM tevents u 
  LEFT OUTER JOIN doctors d 
    ON d.id = u.type
  LEFT OUTER JOIN clients c 
    ON c.id =  u.combo_select
 WHERE u.start_date between '2018.05.23 06:00:00' and '2018.05.23 21:50:00'

M
Melkij, 2018-05-30
@melkij

And where is "such a case"?
In your question, the request has already been completely written, glue the second part to the first part.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question