Welcome Guest, Not a member yet? Register   Sign In
Codeigniter where not exists does not work
#2

(This post was last modified: 10-18-2020, 09:29 PM by ojmichael.)

Why would you not want to use a JOIN? It would certainly be faster than a subquery.

You could probably do something like this (untested):


PHP Code:
$result $this->db->select('POST.ID, POST.DATE, TYPE.Post_type AS P_TYPE, (SELECT ID FROM CATEGORY WHERE CATEGORY.POST_ID = POST.ID) AS CID'false)
  ->
join('TYPE''POST.TYPE_ID = TYPE.ID''left')
  ->
where('POST.ID'$id)
  ->
where_in('TYPE.Post_Type', ['type_1''type_2'])
  ->
order_by('POST.ID''DESC')
  ->
having('CID IS NOT NULL'false)
  ->
get('POST'); 
Reply


Messages In This Thread
RE: Codeigniter where not exists does not work - by ojmichael - 10-18-2020, 09:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB