{"id":90447,"date":"2014-01-11T01:48:58","date_gmt":"2014-01-11T09:48:58","guid":{"rendered":"https:\/\/tri.be\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/"},"modified":"2014-04-17T05:59:04","modified_gmt":"2014-04-17T12:59:04","slug":"missing-table-alias-causing-meta_query-to-fail","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/","title":{"rendered":"Missing Table Alias Causing meta_query to Fail"},"content":{"rendered":"<p>I&#8217;m running into the same problem that was originally brought up in <a href=\"https:\/\/tri.be\/support\/forums\/topic\/wordpress-database-error-not-unique-tablealias-2\">WordPress database error Not unique table\/alias<\/a>. In my case, the error impacts a meta_query I&#8217;ve created that uses the value in a Tribe Events custom field to determine whether an Event should appear on my site&#8217;s home page.<\/p>\n<p>I think I see where the problem is, and I THINK it qualifies as a bug. It&#8217;s in function posts_join() in tribe-event-query.class. The join condition for $joins[&#8216;event_start_date&#8217;] should use a table alias, but doesn&#8217;t. You can see what it <em>should<\/em> be doing in the join condition for $joins[&#8216;event_end_date&#8217;] that immediately follows. That join condition correctly uses an alias (&#8220;as tribe_event_end_date&#8221;).<\/p>\n<p>I was able to get my meta query working again by adding the missing &#8216;tribe_event_start_date&#8217; alias. (I also had to add it to function multi_type_posts_fields(), also in tribe-event-query.class. There may be other &#8220;downstream&#8221; places it needs to be added as well.)<\/p>\n<p>I&#8217;d appreciate your having development review this and, unless I&#8217;m missing something, make the necessary fix.<\/p>\n<p>Thanks.<\/p>\n","protected":false},"template":"","class_list":["post-90447","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Missing Table Alias Causing meta_query to Fail -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Missing Table Alias Causing meta_query to Fail -\" \/>\n<meta property=\"og:description\" content=\"I&#8217;m running into the same problem that was originally brought up in WordPress database error Not unique table\/alias. In my case, the error impacts a meta_query I&#8217;ve created that uses the value in a Tribe Events custom field to determine whether an Event should appear on my site&#8217;s home page. I think I see where [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/\" \/>\n<meta property=\"article:modified_time\" content=\"2014-04-17T12:59:04+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/\",\"name\":\"Missing Table Alias Causing meta_query to Fail -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2014-01-11T09:48:58+00:00\",\"dateModified\":\"2014-04-17T12:59:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Missing Table Alias Causing meta_query to Fail\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Missing Table Alias Causing meta_query to Fail -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/","og_locale":"en_US","og_type":"article","og_title":"Missing Table Alias Causing meta_query to Fail -","og_description":"I&#8217;m running into the same problem that was originally brought up in WordPress database error Not unique table\/alias. In my case, the error impacts a meta_query I&#8217;ve created that uses the value in a Tribe Events custom field to determine whether an Event should appear on my site&#8217;s home page. I think I see where [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/","article_modified_time":"2014-04-17T12:59:04+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/","name":"Missing Table Alias Causing meta_query to Fail -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2014-01-11T09:48:58+00:00","dateModified":"2014-04-17T12:59:04+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/missing-table-alias-causing-meta_query-to-fail\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"Missing Table Alias Causing meta_query to Fail"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/90447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/90447\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=90447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}