Welcome Guest, Not a member yet? Register   Sign In
Delete with Join or Where_in not working
#7

(This post was last modified: 05-05-2020, 02:17 PM by nicolas33770.)

(05-05-2020, 09:35 AM)neuron Wrote: 1. You should do inner join in this case instead of left join (unless $profile_id can be null).
2. In MySQL if you specifying alias for table name you should use alias in delete statement not a table name.
So try this: 
PHP Code:
public function delete_service($location_id,$service_id,$profile_id)
{
    $this->db->from('service s');
    $this->db->join('location l''s.location_id = l.location_id');
    $this->db->where('s.service_id'$service_id);
    $this->db->where('s.location_id'$location_id);
    $this->db->where('l.profile_id'$profile_id);

    return $this->db->delete('s');


Thanks for your replay, I tried but seems join is ignored in final query. Don't working.

(05-05-2020, 12:42 PM)php_rocs Wrote: @nicolas33770,

With query binding you can do any query and it will work.  I prefer it because it more or less goes directly to the db.  I have very strong db skills so I prefer it over having the framework build it for me.


Yes of course. Thank you.  Wink
Reply


Messages In This Thread
RE: Delete with Join or Where_in not working - by nicolas33770 - 05-05-2020, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB