sql - How to get EVENT based on startday, using BETWEEN

I have a SQL query that get all events ordering by Startdate, and i define startday as $today.but this query didn't

I have a SQL query that get all events ordering by Startdate, and i define startday as $today.

but this query didn't take events that start yestarday and that endday is tomorow.

how can i make my query to use BETWEEN ?

my query

SELECT * FROM wp_posts, `wp_mec_dates` AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND dstart>'$startday' and  wp_posts.ID = wp_icl_translations.element_id ORDER BY dstart LIMIT 0,6

startdate is $startday = date("Y-m-d");

EDIT : with documentation & help, i'm here now :

SELECT * FROM wp_posts, wp_mec_dates AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND ($startday BETWEEN dstart AND dend)AND  wp_posts.ID = wp_icl_translations.element_id ORDER BY dstart LIMIT 0,6

but it return 0 results. Any help will be apreciated !

I have a SQL query that get all events ordering by Startdate, and i define startday as $today.

but this query didn't take events that start yestarday and that endday is tomorow.

how can i make my query to use BETWEEN ?

my query

SELECT * FROM wp_posts, `wp_mec_dates` AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND dstart>'$startday' and  wp_posts.ID = wp_icl_translations.element_id ORDER BY dstart LIMIT 0,6

startdate is $startday = date("Y-m-d");

EDIT : with documentation & help, i'm here now :

SELECT * FROM wp_posts, wp_mec_dates AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND ($startday BETWEEN dstart AND dend)AND  wp_posts.ID = wp_icl_translations.element_id ORDER BY dstart LIMIT 0,6

but it return 0 results. Any help will be apreciated !

Share Improve this question edited Jul 17, 2019 at 11:42 Gregory asked Jul 17, 2019 at 9:19 GregoryGregory 6025 silver badges20 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

found the solution <3

Used WHERE '$startday' BETWEEN dstart AND dend

plus : OR dstart >= '$startday'

SELECT * FROM wp_posts, wp_mec_dates AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND ('$startday' BETWEEN dstart AND dend OR dstart >= '$startday') AND  wp_posts.ID = wp_icl_translations.element_id ORDER BY dstart LIMIT 0,6

Try this

WHERE dstart BETWEEN '$startdate' AND '$enddate'

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745315995a4622222.html

相关推荐

  • sql - How to get EVENT based on startday, using BETWEEN

    I have a SQL query that get all events ordering by Startdate, and i define startday as $today.but this query didn't

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信