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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:49:56+00:00 2026-05-28T07:49:56+00:00

I have two tables for storing information about a user. One is for authentication,

  • 0

I have two tables for storing information about a user. One is for authentication, the other is information the user will enter themselves. I am writing a model that will be used when the user interacts with this information. The following method is to return data for display and modification.

I need a query that will return ’email’ and ‘username’ from $accounts_table and * from $profiles_table. I can’t seem to get my head around the JOIN syntax though. I understand how joins work, but my queries throw sentax errors.

function get_userdata($id){
     $data = array();

     $this->db->get_where($this->profiles_table, array('user_id' => $id));
     $this->db->join($this->accounts_table.'.email', $this->accounts_table.'.id = '.$this->profiles_table.'.user_id');
     $data= $this->db->get();

     return $data;
}
  • 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-28T07:49:57+00:00Added an answer on May 28, 2026 at 7:49 am

    I see a couple of issues:

    You should be using $this->db->where(), instead of $this->db->get_where(). get_where() executes the query immediately.

    $this->db->get_where('user_id', $id);
    

    Also the first argument of $this->db->join() should only be the table name, excluding the field.

    $this->db->join($this->accounts_table, $this->accounts_table.'.id = '.$this->profiles_table.'.user_id');
    

    And you’re returning $data which is just an empty array(). You would need to pass the query results to $data like this:

    $data = $record->result_array();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that let user enter values about address information. I want
I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have 2 databases and I need to link information between two big tables
I have a question about best practices regarding how one should approach storing complex
I have two python dictionaries containing information about japanese words and characters: vocabDic :
I am storing information about websites in a table. One set of information is
I have two relational tables: the Profiles table which contains 3 kinds of user
I have two tables with a many-to-one relationship. (Oracle) **Table: PARENT** Field: A (PK)
I have two tables which looks something like this Table Queue int ID; string
I have two tables that are joined together. A has many B Normally you

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.