Codeigniter - 检查数据库中是否存在数组中的值不起作用

I have a table called user where I have a column called sub_teams. I have stored values in there like Construction,Teamwork,Website etc.

I have an announcement table called announcements where I have a body column and a sub_teams column.

All values in both sub_teams column in the users and the announcements has values stored separated by commas. What I want to achieve is that if an announcement has Construction,Website in one of the rows and the user has Website,Teamwork then he is able to view the announcement since he is in the Construction sub_team. Edit: But I want to display all rows of announcements that have the sub_teams not just one.

How can I achieve this? I have tried this:

    $uid = $this->session->userdata('uid');
    $this->db->select('sub_teams');
    $this->db->from('users');
    $this->db->where('uid', $uid);
    $sub_teams_query = $this->db->get();
    $sub_teams_result = $sub_teams_query->row();
    $sub_teams = explode(',', $sub_teams_result->sub_teams);

    $this->db->limit($limit, $start);
    $this->db->select('*');
    $this->db->from('announcements');
    $this->db->where('active', 1);
    $this->db->where('date_created <', date('Y-m-d H:m:s')); //hide the announcements that are new and not published yet.

    foreach ($sub_teams as $sub_team) {
        $this->db->or_like('view_sub_teams', $sub_team);
    }


    $this->db->join('users', 'users.uid = announcements.uid');
    $this->db->order_by('date_created', 'desc', 'after');
    $query = $this->db->get();

It seems to not work as it displays every single announcement. Thanks guys.

If im not wrong, you are fetching announcements for a particular user. Its returning all rows because in second query, you have missed where for userId condition

$this->db->where('uid', $uid);

Add the where condition in your second query.