Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easier way?

Status
Not open for further replies.

KarveR

MIS
Dec 14, 1999
2,065
GB
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.
 
Come on Sleip wakey wakey :) .. I dunno, I wander off and drop from the forum experts list and return with a challenge .. and where are you .. sleeping at a guess.

Wheres the admin, change his name to SLEEPNir214 :p

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top