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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:35:03+00:00 2026-05-24T05:35:03+00:00

SELECT `users`.* FROM (`users`) JOIN `users_profiles` ON `users_profiles`.`user_id` = `users`.`id` JOIN `albums` ON `albums`.`user_id`

  • 0
SELECT `users`.*
FROM (`users`)
JOIN `users_profiles` ON `users_profiles`.`user_id` = `users`.`id`
JOIN `albums` ON `albums`.`user_id` = `users`.`id`
JOIN `users_sites` ON `users_sites`.`user_id` = `users`.`id`
WHERE `users`.`id` = 4 

That’s my query. I have data in users, users_profiles, albums, and users_sites. Currently I’m getting the necessary data in four separate queries but I want to optimise with JOINs.

My problem is that the result set being returned only contains one row of data from the users table (where the id is 4). This is to be expected but I want other tables JOINed on the end too.

For example, users_profiles contains a row that I have confirmed contains user_id set to 4. But no rows from users_profiles is ever added to the query, all I see is what comes from users.

Any ideas? It’s the same case for the other tables – I’ve confirmed they should be selected properly but I’m not sure what I’m doing wrong.

Thanks for your help!

  • 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-24T05:35:07+00:00Added an answer on May 24, 2026 at 5:35 am

    Try:

    SELECT `users`.*, `users_profiles`.*, `albums`.*, `users_sites`.*
    FROM (`users`)
    JOIN `users_profiles` ON `users_profiles`.`user_id` = `users`.`id`
    JOIN `albums` ON `albums`.`user_id` = `users`.`id`
    JOIN `users_sites` ON `users_sites`.`user_id` = `users`.`id`
    WHERE `users`.`id` = 4 
    

    Your code only selecting the columns from users table.

    Alternatively,

    SELECT *
    FROM (`users`)
    JOIN `users_profiles` ON `users_profiles`.`user_id` = `users`.`id`
    JOIN `albums` ON `albums`.`user_id` = `users`.`id`
    JOIN `users_sites` ON `users_sites`.`user_id` = `users`.`id`
    WHERE `users`.`id` = 4 
    

    Please beware that selecting * is not recommended as it is not optimized. Just select the column that you need.

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

Sidebar

Related Questions

Say I have the following: $query = SELECT user_id,email,password, roles.role_id,role_name FROM users JOIN roles
i have sql query select * from Roles Join Users On Roles.Role=Users.RoleId it return
I have the following query: SELECT c.* FROM companies AS c JOIN users AS
I have a following SQL QUERY: SELECT articles.name, articles.price, users.zipcode FROM articles INNER JOIN
I currently have a query similar to: SELECT users.fname, users.lname, sales.date FROM users LEFT
I have a query that returns all stream posts from users (with comments): SELECT
i have this SELECT COUNT(1) cnt, a.auther_id FROM `posts` a LEFT JOIN users u
I Want To Join 2 Selections one: SELECT user_email FROM users WHERE user_id =
UPDATE users u JOIN (select count(*) as job_count, user_id from job_responses where date_created >
In this query: SELECT COUNT(*) AS UserCount, Company.* FROM Company LEFT JOIN User ON

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.