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 9225685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:38:35+00:00 2026-06-18T04:38:35+00:00

Here is my query: SELECT user.*, @UserID:=user.uid, (SELECT count(c1) FROM ( SELECT COUNT(*) AS

  • 0

Here is my query:

SELECT user.*, @UserID:=user.uid,
    (SELECT count(c1) FROM (
    SELECT COUNT(*) AS c1 FROM user_group
    WHERE user_group.uid=@UserID
    GROUP BY user_group.uid
) x1) AS x2

FROM user 

Problem is that @UserID in not passed to sub-query

  • 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-06-18T04:38:37+00:00Added an answer on June 18, 2026 at 4:38 am

    how about using JOIN? I think the result is the same as what you want. And I’m guessing that you want to get the total number of group the user has. Right?

    SELECT  a.*, 
            COALESCE(b.totalCount, 0) totalCount,
            COALESCE(b.totalType, 0) totalType
    FROM    user a
            LEFT JOIN
            (
                SELECT  uid, 
                        COUNT(*) totalCount, 
                        COUNT(DISTINCT type) totalType
                FROM    user_Group 
                GROUP BY uid
            ) b ON a.uid = b.uid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my sample query: SELECT userid,count(*) FROM hits GROUP BY userid My table
here is the query SELECT * FROM customers WHERE NOT EXISTS ( SELECT 1
The following MySQL query: select `userID` as uID, (select `siteID` from `users` where `userID`
Here is my query: SELECT DISTINCT `c`.`user_id`, `c`.`created_at`, `c`.`body`, (SELECT COUNT(*) FROM profiles_comments c2
Here's my query SELECT * FROM wp_postmeta WHERE meta_value LIKE '.$_POST['username'].' AND meta_value LIKE
Here's the query: SELECT COUNT(*) AS c, MAX(`followers_count`) AS max_fc, MIN(`followers_count`) AS min_fc, MAX(`following_count`)
Here is my query Select Gender from Table The result pane shows 1 1
Here is my Query : select EmployeeName, EmployeeSalary from Employee2 for xml path('EmployeeDetails') returns
Here is my query select t1.*, t2.name as customer, t2.name as vendor from order
Here is my query select * from table1 inner join table2 on table1.typeId=table2.typeId; This

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.