Nitesh Jha
Nitesh Jha

Reputation: 17

INNER JOIN ON condition in codeigniter

this is my mysql query

SELECT MAX(A.BID),B.* 
  FROM tbl_bid A 
 INNER 
  JOIN wl_customers B 
    ON A.customers_id=B.customers_id
 WHERE portfolio_id='$Id'

how to write this query in codeigniter.

Upvotes: 2

Views: 1230

Answers (3)

Kumar Rakesh
Kumar Rakesh

Reputation: 2708

Try with this query. It may be helpful for you :

$this->db->select("B.*","MAX(A.BID)")
            ->from("tbl_bid A")
            ->join("wl_customers B","A.customers_id=B.customers_id")
            ->where("portfolio_id",$Id)->get()->result();

Upvotes: 0

Nishant Nair
Nishant Nair

Reputation: 2007

You can also try. This can also be one of the way

     $this->db->select('MAX(A.BID),wl_customers.*');
     $this->db->from('tbl_bid');
     $this->db->join('wl_customers ','tbl_bid.customers_id=wl_customers.customers_id');
     $this->db->where('portfolio_id',$Id,false)
     $result = $this->db->get();

Upvotes: 1

reignsly
reignsly

Reputation: 502

Something like

$this->db->select('MAX(A.BID),B.*')
->join('wl_customers as B','A.customers_id=B.customers_id')
->where('portfolio_id',$Id)
->get('tbl_bid as A')
->row();

Upvotes: 0

Related Questions