I would like to declare a variable to eliminate double entry when entering date information into a 'WHERE' clause. However, the database is read-only and isn't letting me declare anything. This is what I have tried:
SET @begin_date = '2017-12-01'
SET @end_date = '2017-12-30'
WHERE (ship.dateShipped BETWEEN @begin_date AND @end_date)
OR (fulfill.datefulfilled BETWEEN @begin_date AND @end_date)
The query is simplified for the sake of this post, but is basically what I am trying to do. I have to hand this off to a salesman to run as needed, and want to make it as easy as possible to change the date parameters.
Is there a way to declare variables in this scenario? Or maybe an alternate way to write the 'WHERE' clause so the dates only have to be entered once?
I have also tried:
SELECT @begin_date := '2017-12-01', @end_date := '2017-12-30'......
and also
DECLARE begin_date INT unsigned DEFAULT '2017-12-01'
DECLARE end_date INT unsigned DEFAULT '2017-12-30'
to no avail.