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

  • SEARCH
  • Home
  • 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 6195437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:28:07+00:00 2026-05-24T03:28:07+00:00

So I have a bookmark table for which i am trying to get the

  • 0

So I have a “bookmark” table for which i am trying to get the “UserID”s of the users that have bookmark the most content. This query returns the UserID of the ten most active users. This query looks like this for me and works:

SELECT COUNT(*) AS `Rows`, UserID FROM `bookmark`
WHERE UserID NOT IN(1, 2, 25, 38, 41, 43, 47, 125) 
GROUP BY UserID ORDER BY `Rows` DESC LIMIT 10 

Now i am trying to join the result queries to the “accounts” table to get all the info of each user ID by comparing the UserID to the “id” in the accounts table.

SELECT COUNT(*) AS `Rows`, UserID FROM `bookmark`
join accounts ON accounts.ID = bookmark.UserID
WHERE UserID NOT IN(1, 2, 25, 38, 41, 43, 47, 125) 
GROUP BY UserID ORDER BY `Rows` DESC LIMIT 10 

This is not returning any of the rows as the accounts table but is instead returning the same result as before. I need to be able to get all the rows of the accounts table (same thing as using *)

If it helps my accounts table has these rows = user_name, id, email and my bookmark table has these rows = id, UserId, link

  • 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-24T03:28:08+00:00Added an answer on May 24, 2026 at 3:28 am

    One solution is to move the group by to a subquery:

    select  *
    from    (
            select  count(*) as Rows
            ,       UserID 
            from    bookmark
            where   UserID not in (1, 2, 25, 38, 41, 43, 47, 125) 
            group by
                    UserID 
            ) as BookmarkSubquery
    join    accounts
    on      accounts.ID = BookmarkSubquery.UserID
    order by
            BookmarkSubquery.Rows DESC 
    limit   10 
    

    Another is to add the columns from accounts to the group by:

    select  count(*) as Rows
    ,       bookmark.UserID 
    ,       accounts.Name
    ,       accounts.BirthDate
    from    bookmark
    join    accounts
    on      accounts.ID = BookmarkSubquery.UserID
    where   bookmark.UserID not in (1, 2, 25, 38, 41, 43, 47, 125) 
    group by
    ,       bookmark.UserID 
    ,       accounts.Name
    ,       accounts.BirthDate
    order by
            count(*) DESC 
    limit   10 
    

    Note: MySQL allows you to list only bookmark.UserID in the group by; although that will work, it’s not recommended.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some jquery to get around this problem: iPhone "Bookmark to Homescreen"
I have a word document with a bookmark. I use the bookmark to get
I have a C# WCF REST Service which allows the addition of a bookmark,
I have the following code which works great:- $('.ajax a').click(function() { getpageajax(this.href); return false;
I am trying to construct equivalent of this code in JSF2 <form action=/search.xhtml method=get>
I have some code in my application that looks something like this: char *hash
I have a database that stores thousands of bookmarks and the table BM_Table has
Environment: Workflow Foundation 4, SQL persistence store. Requirement: I have a bookmark which has
I'm trying to reload a table which was also generated by PHP. The table
Using CoreData, I have an entity Bookmark, that has an to-many relationship named 'tags'

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.