mysql - Find entries depending from actual date -


how find specific entries database table. need values of ref when today's date betwenn start , end , state 1. if date not between start , end need values of ref if start , end '0000-00-00' , state 1.

ref start end state 1 0000-00-00 0000-00-00 1 1 2015-07-18 2015-09-05 1 2 0000-00-00 0000-00-00 0 2 2015-05-23 2015-09-04 0 3 0000-00-00 0000-00-00 1 4 2015-07-18 2015-09-05 0 5 0000-00-00 0000-00-00 1 5 2015-07-18 2015-09-05 0 6 0000-00-00 0000-00-00 1 6 2015-07-18 2015-09-05 1 7 0000-00-00 0000-00-00 1 7 2015-06-27 2015-09-04 0 8 0000-00-00 0000-00-00 1 8 2015-06-27 2015-09-04 0 9 0000-00-00 0000-00-00 1 9 2015-06-27 2015-09-04 0 10 0000-00-00 0000-00-00 0 10 2015-06-27 2015-09-04 1 11 0000-00-00 0000-00-00 1 11 2015-06-27 2015-09-04 0 12 0000-00-00 0000-00-00 1 12 2015-06-27 2015-09-04 0 13 0000-00-00 0000-00-00 1 13 2015-05-23 2015-09-04 0 14 0000-00-00 0000-00-00 0 14 2015-05-23 2015-09-04 1 15 0000-00-00 0000-00-00 1 15 2015-05-23 2015-09-04 0 16 0000-00-00 0000-00-00 1 16 2015-05-23 2015-09-04 0 17 0000-00-00 0000-00-00 1 17 2015-05-23 2015-09-04 0

try this:

select ref table state = 1     , ((mydate between start , end)     or (start = 0000-00-00 , end=0000-00-00 , mydate not between start , end)) 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -