Hello, I hope someone can help – I have the following query code that pulls out individual values from a channel for a select dropdown, but I want to add another field to it, have tried adding , and putting each select in () but nothing seems to work, can anyone help?
The query I have is:
{exp:query sql="SELECT DISTINCT field_id_52 FROM exp_channel_data_field_52 INNER JOIN exp_channel_titles ON exp_channel_titles.entry_id = exp_channel_data_field_52.entry_id WHERE exp_channel_titles.`status` = 'open' ORDER BY field_id_52 ASC"}
<option value="{field_id_52}" class="{field_id_108}">– {field_id_52}</option>{/if}
{/exp:query}
Which works, but i’d also like to output the value from field_id_108 from the same entry, sorry if this is a stupid question, or if anyone knows / can suggest anything that would work as well - I can’t work it out, thank you
If what you are trying to do is to extend the join to include the extra field you could try this
SELECT field_id_52, field_id_108 FROM exp_channel_data_field_52
JOIN exp_channel_data_field_108 ON exp_channel_data_field_52.entry_id = exp_channel_data_field_108.entry_id
JOIN exp_channel_titles ON exp_channel_titles.entry_id = exp_channel_data_field_52.entry_id
WHERE exp_channel_titles.status = 'open' ORDER BY field_id_52;
But I’m unclear why you would do this when you can achieve the same thing using EE tags… (which has the advantage of being indifferent to the naming of of the MySQL fields associated with the variables used by EE etc.
Anyhow, HTH
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.