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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:57:19+00:00 2026-05-28T03:57:19+00:00

hi i am using codeigniter , and i have a table like this i

  • 0

hi i am using codeigniter , and i have a table like this

enter image description here

i want to get all records where PreferenceID value is not in PreferenceParentID column

in this case i am fitering table also with the EntityID . and PreferenceParentID shoul be != 0

suppose i filter by entityID 53

my results shoul be

Couture , Denims

because PreferenceID is not in PreferenceParentID in both cases . i tried with where_not_in() but could not do . please help

this is my query

    $table = $this->mastables['shop_profile_preferences'];
    $this->db->select('a.ProfilePreferenceID');
    $this->db->from($table." as a");

    $where2 = "(SELECT a.PreferenceParentID FROM ".$table.")";
    $this->db->where_not_in('a.PreferenceID', $where2);

    $this->db->where("a.EntityID",$shop_id);
    $this->db->where('a.PreferenceParentID !=',0);

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

    if($query->num_rows()>0)
    {
        return $query->result_array();
    }
    else
    {
        return FALSE;
    }

the result of my query is

Array
(
    [0] => Array
        (
            [ProfilePreferenceID] => 274
        )

    [1] => Array
        (
            [ProfilePreferenceID] => 275
        )

    [2] => Array
        (
            [ProfilePreferenceID] => 276
        )

)

how to use where_not_in() properly . or ids there any other methods . please help …..
thanks in advance .

UPDATE

    $table = $this->mastables['shop_profile_preferences'];
    $this->db->select('a.ProfilePreferenceID,a.ProfilePreferenceValue');
    $this->db->from($table." as a");

    $this->db->where('a.PreferenceParentID !=',0);
    $this->db->where('a.PreferenceID NOT IN (SELECT a.PreferenceParentID FROM '.$table.')', NULL, FALSE);
    $this->db->where("a.EntityID",$shop_id);

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

    if($query->num_rows()>0)
    {
        return $query->result_array();
    }
    else
    {
        return FALSE;
    }
  • 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-28T03:57:19+00:00Added an answer on May 28, 2026 at 3:57 am

    You can’t do that with CodeIgniter’s where_not_in(). Because the second argument is supposed to be an array and not a string like that.

    What you can do is instead use the usual where() method.

    $this->db->where('a.PreferenceID NOT IN (SELECT a.PreferenceParentID FROM `table_name`)', NULL, FALSE);
    

    In case you’re wondering, the third argument in the code above is to prevent CodeIgniter from trying to protect the field and table name with backticks.

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

Sidebar

Related Questions

I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,
I have this function on my controller (Im using CodeIgniter) that reads the database,
I am using codeigniter. My products page shows all the products we have and
In CodeIgniter I'm using a base CRUD My_model , but I have this small
I have a date field in a mysql table formatted like this: Y-m-d. I
I have two tables, categories and products. I am using CodeIgniter. Categories CREATE TABLE
Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
I have this syntax for grabbing some data from database, I using codeigniter's active
I'm using codeigniter for this project. I have a search form and search form
I have a MYSQL table column of type timestamp and using CURRENT_TIMESTAMP as default

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.