Codeigniter where not exists does not work |
I'm working on Codeigniter project and came across a problem. I would like that my function on my model to bring me the data from the POST table, where POST_ID in CATEGORY Table is not null, without joining the table, so (do not bring back the data whose POST_ID in CATEGORY table not exists). so i tried this method how can i get this result?
Code: code: // MyModel Thank you for help
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)
Thank you for replying i tried this code but i get this error : ORA-00933 SQL Command Not Properly Ended
Thank you for replying i tried this code but i get this error : ORA-00933 SQL Command Not Properly Ended
Your if statement is going to always work because both values assigned to $id
will not be null as you think it will be if you want to check it to null replace '' with null. PHP type comparison tables What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |