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

The Archive Base Latest Questions

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

I have two tables: ‘events_archive’ and ‘demo_users’. In the events table, each event has

  • 0

I have two tables: ‘events_archive’ and ‘demo_users’. In the events table, each event has a unique ref_id value, a demo_id value (the user ID of the demonstrator who participated in the event) and a client_id value (the user ID of the client who participated in the event). In the demos table, each demonstrator has a unique id value that corresponds to the demo_id in the events table.

What I want to do is list all demonstrators (from the demos table) that participated in events that a particular client did. I’m getting the particular client’s user ID with session data.

So say the client_id value is 4, I want to list all the individual demonstrators that have shared an event (i.e. shared a row in the table). I’m currently using this in my CodeIgniter model:

function demos($mid){    
   $this->db->select('demo_users.*');
   $this->db->from('demo_users');
   $this->db->join('events_archive','events_archive.demo_id = demo_users.id');
   $this->db->where('events_archive.client_id',$mid);
   $this->db->limit(10);
   $this->db->order_by('users_demonstrators.products_sold','asc');
   $demos = $this->db->get(); 
   foreach($demos->result() as $demo){
      echo $demo->first_name;
   }
}

But instead of listing the demonstrators individually, it duplicates them over and over. Instead of listing Demonstrator A, Demonstrator D, Demonstrator F, etc. it lists Demonstrator A, Demonstrator A, Demonstrator A, etc. Does anybody know where I’m going wrong?

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

    Instead of $this->db->select('demo_users.*') try $this->db->select('*') and instead of echo $demo->first_name; try var_dump($demo);.

    My guess is that Demonstrator A has many records in events_archive. You join the two tables and as a result, each matching record in events_archive gets added with the columns from demo_users. That’s why you get multiple demo_users.* – but the records have different events_archive.* values.

    You maybe want to try SELECT DISTINCT.

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

Sidebar

Related Questions

I have two tables: A (col1,col2,col3,col4) B (col1,col2,col3,col4) Table A has 4 records(rows) and
I have two tables with multiple connections, for example: First table: Tbl_Flights, it has
I have two tables a and b . Table a has a field named
I have two tables I'm trying to join and get a unique value in
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have two tables, a user table and a application table: User id username
I have two tables connected with one to many relationship. Parent Table is a
I have two tables objects and tags , each object having an id, and

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.