We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

SOLVED - Query module – multiple custom fields

How Do I?

's avatar
2 posts
3 years ago
's avatar

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

       
JCOGS Design's avatar
JCOGS Design
148 posts
3 years ago
JCOGS Design's avatar JCOGS Design

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

       
's avatar
2 posts
3 years ago
's avatar

Thank you - sorry, am not very good with all of this

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.