Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 648905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:53:02+00:00 2026-05-13T21:53:02+00:00

I’ve been at this for a bit now. Basically, I’m needing to add a

  • 0

I’ve been at this for a bit now. Basically, I’m needing to add a derived column to count the hits to a weblog entry in the database. The problem is, the hits are being totaled and shown on only on the first record. Any Ideas? I’ve emboldened the parts of the query I’m talking about. The query is below:

SELECT DISTINCT(t.entry_id), 
    exp_categories.rank, 
    **exp_hits.hits,** 
    t.entry_id, 
    t.weblog_id, 
    t.forum_topic_id, 
    t.author_id, 
    t.ip_address, 
    t.title, 
    t.url_title, 
    t.status, 
    t.dst_enabled, 
    t.view_count_one, 
    t.view_count_two, 
    t.view_count_three, 
    t.view_count_four, 
    t.allow_comments, 
    t.comment_expiration_date, 
    t.allow_trackbacks, 
    t.sticky, 
    t.entry_date, 
    t.year, 
    t.month, 
    t.day, 
    t.entry_date, 
    t.edit_date, 
    t.expiration_date, 
    t.recent_comment_date, 
    t.comment_total, 
    t.trackback_total, 
    t.sent_trackbacks, 
    t.recent_trackback_date, 
    t.site_id as entry_site_id, 
    w.blog_title, 
    w.blog_name, 
    w.search_results_url, 
    w.search_excerpt, 
    w.blog_url, 
    w.comment_url, 
    w.tb_return_url, 
    w.comment_moderate, 
    w.weblog_html_formatting, 
    w.weblog_allow_img_urls, 
    w.weblog_auto_link_urls, 
    w.enable_trackbacks, 
    w.trackback_use_url_title, 
    w.trackback_field, 
    w.trackback_use_captcha, 
    w.trackback_system_enabled, 
    m.username, 
    m.email, 
    m.url, 
    m.screen_name, 
    m.location, 
    m.occupation, 
    m.interests, 
    m.aol_im, 
    m.yahoo_im, 
    m.msn_im, 
    m.icq, 
    m.signature, 
    m.sig_img_filename, 
    m.sig_img_width, 
    m.sig_img_height, 
    m.avatar_filename, 
    m.avatar_width, 
    m.avatar_height, 
    m.photo_filename, 
    m.photo_width, 
    m.photo_height, 
    m.group_id, 
    m.member_id, 
    m.bday_d, 
    m.bday_m, 
    m.bday_y, 
    m.bio, 
    md.*, 
    wd.* 
FROM exp_weblog_titles AS t 
    LEFT JOIN exp_weblogs AS w ON t.weblog_id = w.weblog_id 
    LEFT JOIN exp_weblog_data AS wd ON t.entry_id = wd.entry_id 
    LEFT JOIN exp_members AS m ON m.member_id = t.author_id 
    LEFT JOIN exp_member_data AS md ON md.member_id = m.member_id 
    LEFT JOIN exp_category_posts ON wd.entry_id = exp_category_posts.entry_id 
    **LEFT JOIN
    (
        SELECT COUNT(*) AS hits, exp_hits.entry_id FROM exp_hits ORDER BY exp_hits.entry_id
    ) exp_hits ON t.entry_id = exp_hits.entry_id**
    LEFT JOIN 
    ( 
        SELECT exp_categories.cat_id, cat_name as rank 
        FROM exp_categories 
        WHERE exp_categories.group_id = '9' 
    ) exp_categories ON exp_categories.cat_id = exp_category_posts.cat_id 
WHERE t.entry_id IN (2,3,4) ORDER BY exp_categories.rank DESC, **exp_hits.hits DESC**, entry_date desc
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:53:03+00:00Added an answer on May 13, 2026 at 9:53 pm

    Try changeing the subselect to

    SELECT COUNT(*) AS hits, 
        exp_hits.entry_id 
    FROM exp_hits 
    GROUP BY exp_hits.entry_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 319k
  • Answers 319k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you do a UPDATE LOW_PRIORITY table ... you will… May 14, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer To specify order of substitution, use %1$@ and %2$@ as… May 14, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer I hate to sound like an grumpy, old academic, but… May 14, 2026 at 12:12 am

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.