admin管理员组文章数量:1419912
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 badges2 Answers
Reset to default 0found 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'
本文标签: sqlHow to get EVENT based on startdayusing BETWEEN
版权声明:本文标题:sql - How to get EVENT based on startday, using BETWEEN 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745315995a2653157.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论