Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT DISTINCT wp_posts.*, MIN(wp_postmeta.meta_value) as EventStartDate, tribe_event_end_date.meta_value as EventEndDate
- FROM wp_posts
- LEFT JOIN wp_postmeta
- ON ( wp_posts.ID = wp_postmeta.post_id )
- LEFT JOIN wp_postmeta AS mt1
- ON (wp_posts.ID = mt1.post_id
- AND mt1.meta_key = '_EventCost' )
- LEFT JOIN wp_postmeta as tribe_event_end_date
- ON ( wp_posts.ID = tribe_event_end_date.post_id
- AND tribe_event_end_date.meta_key = '_EventEndDate' )
- WHERE 1=1
- AND ( ( wp_postmeta.meta_key = '_EventCost'
- AND CAST(wp_postmeta.meta_value AS SIGNED) = '0' )
- OR mt1.post_id IS NULL )
- AND wp_posts.post_type = 'tribe_events'
- AND (wp_posts.post_status = 'publish'
- OR wp_posts.post_status = 'private')
- AND tribe_event_end_date.meta_value < '2015-06-18 23:59:59'
- GROUP BY wp_posts.ID
- ORDER BY EventStartDate DESC
- LIMIT 0, 1
Advertisement
Add Comment
Please, Sign In to add comment