Title: Bug query sql
Last modified: December 22, 2020

---

# Bug query sql

 *  Resolved Anonymous User 18162847
 * (@anonymized-18162847)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/bug-query-sql/)
 * Hello,
 * On the calendar page, I can’t find any event.
    I have many events in the admin.
 * I looked at the problem and I get a SQL error:
    `SELECT wp_posts.ID, CAST( orderby_event_date_meta.
   meta_value AS DATETIME ) AS event_date, CAST( orderby_event_duration_meta.meta_value
   AS DECIMAL ) AS event_duration FROM wp_posts LEFT JOIN wp_postmeta ON (wp_posts.
   ID = wp_postmeta.post_id AND wp_postmeta.meta_key = '_EventHideFromUpcoming' )
   LEFT JOIN wp_postmeta tribe_start_date_utc ON ( wp_posts.ID = tribe_start_date_utc.
   post_id AND tribe_start_date_utc.meta_key = '_EventStartDate' ) LEFT JOIN wp_postmeta
   tribe_end_date_utc ON ( wp_posts.ID = tribe_end_date_utc.post_id AND tribe_end_date_utc.
   meta_key = '_EventEndDate' ) LEFT JOIN wp_postmeta AS orderby_event_date_meta
   ON ( orderby_event_date_meta.post_id = wp_posts.ID AND orderby_event_date_meta.
   meta_key = '_EventStartDate' ) LEFT JOIN wp_postmeta AS orderby_event_duration_meta
   ON ( orderby_event_duration_meta.post_id = wp_posts.ID AND orderby_event_duration_meta.
   meta_key = '_EventDuration' ) WHERE 1=1 AND ((())) AND ( wp_postmeta.post_id 
   IS NULL ) AND wp_posts.post_type = 'tribe_events' AND ((wp_posts.post_status 
   = 'publish' OR wp_posts.post_status = 'private')) AND (( TIMESTAMPDIFF ( SECOND,
   tribe_start_date_utc.meta_value, '2021-01-04 23:59:59' ) >= 2 AND TIMESTAMPDIFF(
   SECOND, '2020-11-30 00:00:00', tribe_end_date_utc.meta_value ) >= 2 )) GROUP 
   BY wp_posts.ID ORDER BY event_date ASC, event_duration ASC, wp_posts.menu_order
   ASC`
 * Here is the query, you can see “AND ((())) “, if you remove them the query works
   well.
 * Do you have an idea of the problem and where the parenthesis comes from?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fbug-query-sql%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

The topic ‘Bug query sql’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

## Tags

 * [event](https://wordpress.org/support/topic-tag/event/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 0 replies
 * 1 participant
 * Last reply from: Anonymous User 18162847
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/bug-query-sql/)
 * Status: resolved