ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Tricky SQL to get entry count by category - any SQL gurus out there?

September 24, 2011 7:21pm

Subscribe [2]
  • #1 / Sep 24, 2011 7:21pm

    Versa Studio

    572 posts

    I have entries that appear in two category groups:

    Appears on site
      Dolphin Project
      Save Japan Dolphins

    Blog
      Taiji - Cove
      Indonesia Dolphin Protection
      Solomon Islands
      Trade in Live Dolphins
      Mercury
      Whales
      Captivity Industry

    I need some SQL to count entries in each of the categories under ‘blog’ which also appear in ‘dolphin project’.  So I need to count entries in ‘Taiji Cove’ and ‘Dolphin Project’, and then ‘Indonesia Dolphin Protection’ and ‘Dolphin Project’ and so on.

    The table exp_category_posts looks like this, that is, there are multiple rows for each entry_id.

    entry_id   cat_id
    1          1
    1          2
    1          3

    Ideas?

     

  • #2 / Sep 24, 2011 7:40pm

    John St-Amand

    865 posts

    Bjorn Boressen’s Categories add-on gives you the ability to quickly and easily pull entry counts within a category.  Just one of many options I’m sure.  But then you wouldn’t need to do a query since the plugin would do it for you.  Hope that helps.

  • #3 / Sep 24, 2011 10:20pm

    Versa Studio

    572 posts

    Thanks John, that did the trick!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases