0

How can I pass in join hints to codeigniter?

I want to run the following SQL query:

SELECT t1.a, t2.b FROM t1
INNER HASH JOIN t2 on t1.id = t2.id

How do I do run the above query with codeigniter? You can specify the join type, but you cannot pass in a join hint.

Pio
  • 4,044
  • 11
  • 46
  • 81
  • 1
    i'm not sure if you can do that - if you take a look here https://github.com/bcit-ci/CodeIgniter/blob/develop/system/database/DB_query_builder.php#L529 you pretty much see whats going on here - and extending this class is a pretty tough job - so in that case the only thing you can do is `$query = $this->db->query('SELECT t1.a, t2.b FROM t1 INNER HASH JOIN t2 on t1.id = t2.id');` – Atural Sep 06 '18 at 08:15
  • Thanks, I'll just use the `query` then interface. – Pio Sep 19 '18 at 06:51

1 Answers1

-1
    you can simply load database library and use below code to exicute join query  

    $this->db->select('t1.a,t2.b');
    $this->db->from('t1');
    $this->db->join('t2', 't1.id = t2.id','INNER'); //You can use multiple joins same like this  
    //$this->db->where('t1.id','123'); // if required use where tag
    $query = $this->db->get()->result(); // $query conatin query result 
Sachin
  • 789
  • 5
  • 18
  • OP is using `sql-server` and is asking for a specific type of join like `INNER HASH JOIN` which isn't currently possible in CIs query builder... – Atural Sep 06 '18 at 08:17
  • Please read my question again, as @sintakonte said, I need to use `INNER HASH JOIN`. – Pio Sep 06 '18 at 14:18