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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:42:37+00:00 2026-06-17T07:42:37+00:00

I have this query as my main query, I use all the records from

  • 0

I have this query as my main query, I use all the records from the members table, and selected columns from comments and chat_box.

SELECT members.*, 
       a.commenter_id, 
       b.user_id, 
       a.comcount, 
       b.chatcount 
FROM   members 
       LEFT JOIN (SELECT commenter_id, 
                         Count(*) comCount 
                  FROM   comments 
                  GROUP  BY commenter_id) a 
              ON members.id = a.commenter_id 
       LEFT JOIN (SELECT user_id, 
                         Count(*) chatCount 
                  FROM   chat_box 
                  GROUP  BY user_id) b 
              ON members.id = b.user_id 
WHERE  members.id = '290' 

I would like to add this query to the above

SELECT Count(friend_id) AS totFriend, 
       friend_id        AS fi, 
       logged_user_id   AS user, 
       friend_accepted  AS fa 
FROM   member_friends 
WHERE  logged_user_id = '1' 
       AND friend_id = '290' 

Is it possible to add this to the mix without causing any errors? I have tried it myself but I maybe just putting my self in deeper problems. If it is possible could someone assist me in doing so, thank you :).

  • 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-17T07:42:38+00:00Added an answer on June 17, 2026 at 7:42 am

    If you have a way to join the last query to your members table, then you should be able to use:

    SELECT members.*, 
      a.commenter_id, 
      b.user_id, 
      a.comcount, 
      b.chatcount,
      c.totFriend
    FROM   members 
    LEFT JOIN 
    (
      SELECT commenter_id, 
        Count(*) comCount 
      FROM   comments 
      GROUP  BY commenter_id
    ) a 
      ON members.id = a.commenter_id 
    LEFT JOIN 
    (
      SELECT user_id, 
        Count(*) chatCount 
      FROM   chat_box 
      GROUP  BY user_id
    ) b 
     ON members.id = b.user_id 
    LEFT JOIN
    (
      SELECT Count(friend_id) AS totFriend, 
           friend_id        AS fi, 
           logged_user_id   AS user, 
           friend_accepted  AS fa 
      FROM   member_friends 
      WHERE  logged_user_id = '1' 
       AND friend_id = '290'
    ) c
      on members.id = c.friend_id
    WHERE  members.id = '290' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query... SELECT Distinct([TargetAttributeID]) FROM (SELECT distinct att1.intAttributeID as [TargetAttributeID] FROM AST_tblAttributes
I have this query: SELECT * From checkfinale where AssociateID = 51 AND `CompletedDate`
I have this problem, Using a query as follows: mysql_query(SELECT * FROM mytable WHERE
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
i have this query: SELECT `completed`.`ID` AS `ID`,`completed`.`level` AS `level`,`completed`.`completed_in` AS `completed_in`, COUNT(1) AS
I have this query SELECT zip, ( 3959 * acos( cos( radians(34.12520) ) *
how can I use Zend_Db_Select to directly select from a subquery (derived table)? See,
I have this query below. There are 4 main tables involved: tblOrder, tblItems, tblOrder_archive,
I have this code in Access: SELECT DISTINCT p.course, p.date FROM Student s, Participation
I have this query which on executing in my sql command line client executes

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.