is there an easier way of doing this:
SELECT @startday:=if(dayofweek(curdate())=1,@startday:=(1+6),@startday:=(dayofweek(curdate()))+6), @endday:=if(dayofweek(curdate())=1,@endday:=1,@endday:=dayofweek(curdate())), o.data1, o.data2, o.data3, o.data4, o.data5, o.data6, o.data7, o.data8, o.final, l.data1, l.data2, l.final FROM ORIGINAL o, LINKED l WHERE o.data1 = l.data1 AND o.data2='CUST' AND o.data3 >= 'date_sub(curdate(), interval @startday day)' AND o.data3 <= (date_sub(curdate(), interval @endday day)) AND l.data2 > '0' ORDER BY o.data1;
?
It selects the previous week-ago-sunday and teh following saturday anthen collects data from the inclusive week.
Just seems so ..... messy.
PS ignore field names and typos therein, this is a test of ability on auto date creation (MySQL 3.23.54 btw)
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
SELECT @startday:=if(dayofweek(curdate())=1,@startday:=(1+6),@startday:=(dayofweek(curdate()))+6), @endday:=if(dayofweek(curdate())=1,@endday:=1,@endday:=dayofweek(curdate())), o.data1, o.data2, o.data3, o.data4, o.data5, o.data6, o.data7, o.data8, o.final, l.data1, l.data2, l.final FROM ORIGINAL o, LINKED l WHERE o.data1 = l.data1 AND o.data2='CUST' AND o.data3 >= 'date_sub(curdate(), interval @startday day)' AND o.data3 <= (date_sub(curdate(), interval @endday day)) AND l.data2 > '0' ORDER BY o.data1;
?
It selects the previous week-ago-sunday and teh following saturday anthen collects data from the inclusive week.
Just seems so ..... messy.
PS ignore field names and typos therein, this is a test of ability on auto date creation (MySQL 3.23.54 btw)
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.