Hello,
I’m trying to return the sum of the contents of a custom field. I know the below code is not supposed to work, but does…
Is the only link between these two tables the field_id=“n” and field_id_n ?
AND, is there a way to do the below in a single query? I suspect a join is needed in there, but again, me and SQL just started being friendly.
{exp:query sql="SELECT field_id AS get_the_id FROM exp_weblog_fields WHERE field_name='12ozcans'"}
{exp:query sql="SELECT SUM(field_id_{get_the_id}) AS can_total FROM exp_weblog_data"}
{can_total}
{/exp:query}
{/exp:query}Any help would be appreciated. Eventually I want to pass in the custom field name dynamically.