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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:56:23+00:00 2026-06-14T16:56:23+00:00

I have 3 tables, user – contains user_id | username | fullname | email

  • 0

I have 3 tables,

user - contains user_id | username | fullname | email etcc
user_profile - contains entry_id |user_id| profile_image_id| user_location etcc
user_profile_images - contains image_id| user_id | file_path | file_thumb | date etcc

When a user sign’s up, all the details go to the users table, the user_id is also added to the user_profile table with the rest set default as NULL till the user add’s some profile info.

I have a query in model_users to get all user’s data from these three table and it goes like this;

$this->db->where('users.user_id', $user_id)->select('*')->from('users');
$this->db->join('user_profile', 'user_profile.user_id = users.user_id', 'left');
$this->db->join('user_profile_images','user_profile_images.image_id = user_profile.profile_image_id','left');

It work’s fine only when the profile_image_id field in user_profile is not null, that is when the user has uploaded a pic. In the case where the field is null, the user user_id is not returned even when all the other data are returned.

I can see why this is the case, as my join query requires the field profile_image_id but currently my way around it was to set profile_image_id in user_profile as 1(default), which is the default image and has image_id as 1 and user_id as 0 as it’s the general default image. But i still can’t get over the fact that i need to update that query to make it less of a hack.
Do you guys have any ideas?

  • 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-14T16:56:24+00:00Added an answer on June 14, 2026 at 4:56 pm

    Try

    $this->db->select('*')->select('users.user_id')->from('users')
                    ->join('user_profile', 'user_profile.user_id = users.user_id', 'LEFT')
                    ->join('user_profile_images', 'user_profile_images.image_id = user_profile.profile_image_id', 'LEFT')
                    ->group_by('users.user_id')
                    ->where('users.user_id', $user_id);
                    $query = $this->db->get();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables: USER: user_id (pk); username FIELD: field_id (pk); name METADATA: metadata_id
I have two tables user table user_id | name | 1 | peter |
I have two tables user and email. One user can have multiple emails so
i have four tables user-question contains two columns: questionID, userID, the questions that the
I am facing a situation and need help. I have two tables: user: user_id
I have three tables: user(id, name); tasks(id, user_id, text, date); bonus(id, user_id, sum, date,
I have 3 tables: USER ===== USER_ID(PK) FISRT_NAME LAST_NAME ... ROLES ====== ROLE_ID (PK)
Say I have three tables: User Table { UserId INT, Username NVARCHAR ... }
Say I have two tables User ----- id first_name last_name User_Prefs ----- user_id pref
I have two tables User ID UserName 1 Name1 2 Name2 3 Name3 4

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.