Hey everyone,
I’m using the query module to query the “apps_weblog” to get the entries that have something entered for the custom field called “external_url”, which happens to be the column field_id_32 in the table exp_weblog_data. However, the custom field is a different column name on our production server so I’d have to change the query and have two versions, one for dev and one for prod.
What I want to do is query for the custom field by using it’s name so I don’t have to rely on a column that has a different id based on the order it was created.
Is there a better way to query for this? Here’s my query below.
{exp:query sql="SELECT count(exp_category_posts.entry_id) as apps_post_count, exp_category_posts.cat_id, exp_weblog_titles.title, exp_weblog_titles.weblog_id,
exp_categories.cat_url_title, exp_weblogs.blog_name, exp_weblog_data.field_id_32, exp_weblog_data.entry_id
FROM exp_category_posts, exp_weblog_titles, exp_categories, exp_weblogs, exp_weblog_data
WHERE exp_category_posts.entry_id = exp_weblog_titles.entry_id
AND exp_category_posts.cat_id = exp_categories.cat_id
AND exp_weblog_titles.weblog_id = exp_weblogs.weblog_id
AND exp_weblog_titles.entry_id = exp_weblog_data.entry_id
AND exp_weblog_data.field_id_32 != ''
AND exp_categories.cat_url_title = '{segment_3}'
AND exp_weblogs.blog_name = 'apps_weblog'
GROUP BY exp_category_posts.cat_id"}Thanks in advance.