1

I'm trying to speed my site up with a few direct queries.

Like:

{exp:query sql="SELECT field_id_16 FROM exp_channel_data WHERE channel_id='4' "} {field_id_16}

{/exp:query}

What query will I need to restrict these entries to a certain category? I'll probably need to join exp_category_posts?

2

Off the top of my head I'm pretty sure this should work for you :

SELECT field_id_16 FROM exp_channel_data cd
LEFT JOIN exp_category_posts cp
ON cd.entry_id = cp.entry_id
WHERE cp.cat_id = 1

Change the cp.cat_id = 1 number to whichever category ID you need and I'm fairly certain you should be good to go.

| improve this answer | |
  • No problem. Glad that helped. :-) – Mark Bowen Jul 3 '13 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.