gyrus

SQL for free? filter TEC Filter Bar

Jun 18th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.81 KB | None | 0 0
  1. SELECT DISTINCT wp_posts.*, MIN(wp_postmeta.meta_value) as EventStartDate, tribe_event_end_date.meta_value as EventEndDate
  2. FROM wp_posts
  3. LEFT JOIN wp_postmeta
  4. ON ( wp_posts.ID = wp_postmeta.post_id )
  5. LEFT JOIN wp_postmeta AS mt1
  6. ON (wp_posts.ID = mt1.post_id
  7. AND mt1.meta_key = '_EventCost' )
  8. LEFT JOIN wp_postmeta as tribe_event_end_date
  9. ON ( wp_posts.ID = tribe_event_end_date.post_id
  10. AND tribe_event_end_date.meta_key = '_EventEndDate' )
  11. WHERE 1=1
  12. AND ( ( wp_postmeta.meta_key = '_EventCost'
  13. AND CAST(wp_postmeta.meta_value AS SIGNED) = '0' )
  14. OR mt1.post_id IS NULL )
  15. AND wp_posts.post_type = 'tribe_events'
  16. AND (wp_posts.post_status = 'publish'
  17. OR wp_posts.post_status = 'private')
  18. AND tribe_event_end_date.meta_value < '2015-06-18 23:59:59'
  19. GROUP BY wp_posts.ID
  20. ORDER BY EventStartDate DESC
  21. LIMIT 0, 1
Advertisement
Add Comment
Please, Sign In to add comment