Conditional SELECT MySQL
Posted
by user188693
on Stack Overflow
See other posts from Stack Overflow
or by user188693
Published on 2009-10-12T21:36:06Z
Indexed on
2010/04/30
9:07 UTC
Read the original article
Hit count: 227
Don't know if this is possible, but I'd like to select records based on the field value of recur_type, where the 'm' is the day of the week. If it's a weekly recurring event, I need to make sure this is a day it recurs on, otherwise, I want to return all days. however, I'm getting an empty result set:
SELECT *
FROM wp_fun_bec_events
WHERE start_date <= '2009-10-12'
AND ( end_date >= '2009-10-12'
OR (recur_end > '0' AND recur_end >= '2009-10-12' ) )
AND ('m' IN (
CASE WHEN 'recur_type' = 'weekly'
THEN recur_days
ELSE 's/m/t/w/r/f/a'
END ) )
ORDER BY start_date, start_time
Any ideas??
© Stack Overflow or respective owner