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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:31:06+00:00 2026-05-27T15:31:06+00:00

I’m having an function which gets data from my database, and joins different tables.

  • 0

I’m having an function which gets data from my database, and joins different tables. This is the method:

public function getCallcenterCall() {
    $this->db->select('bedrijf.*, status.status_naam, quickscan.datum_verzonden');
    $this->db->join('quickscan', 'bedrijf.id = quickscan.bedrijf_id');
    $this->db->join('status', 'bedrijf.status = status.status_id');
    $this->db->where('status', '0');

    $query = $this->db->get('bedrijf');

    return $query->num_rows() > 0 ? $query-> result_array() : FALSE;
}

In the table status I got 3 rows: 'id', 'status_id', 'status_naam'. In my view, I output the status_naam, but here it gets wrong.

Instead of giving me the 'status_naam' that belongs to 'status_id=0'; it gives me the 'status_naam' where 'status_id=1'.

The same thing happens if I try to get the 'status_naam' for 'status_id=1' then it gives me the 'status_naam' from 'status_id=2'.

What am I doing wrong? Thanks in advance!

  • 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-27T15:31:06+00:00Added an answer on May 27, 2026 at 3:31 pm

    Is your database setup to use foreign key constraints?

    simple example :

    Tables

    create table `groups`(
    `id` int(10) unsigned not null auto_increment primary key,
    `name` varchar(30) not null,
    `colour` varchar(7) not null,
    `created_at` datetime not null,
    `updated_at` datetime not null
     )engine=innodb;
    
    
    create table `users`(
    `id` int(10) unsigned not null auto_increment primary key,
    `group_id` int(10) unsigned not null,
    `permissions` varchar(255) not null default '{[u, r, d]}',
    `created_at` datetime not null,
    `updated_at` datetime not null,
    index(group_id),
    foreign key(group_id) references groups(id)
    )engine=innodb;
    

    Raw SQL

    select g.name, u.permissions from users as u
    left join groups as g
    on g.id = u.group_id
    where id=1
    

    As you can see you set an index of group_id on the users table,
    then set it as our foreign key and tell it to reference the groups id.

    innodb engine is required & the rows must match identically.

    …hope that makes sense

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I want to construct a data frame in an Rcpp function, but when I
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.