Welcome Guest, Not a member yet? Register   Sign In
mysql: join table when matching OR condition
#1

[eluser]ministry[/eluser]
Hi,

I'm trying to join a table that matches a "condition A" OR a "condition B".

For example:
$this->db->select('tableA.id, tableB.id, tableC.rif_id');
$this->db->from('tableA, tableB');
$this->db->join('tableC', 'tableC.rif_id=tableA.id OR tableC.rif_id=tableB.id');

So tableC should be joined only when tableC.rif_id matches tableA.id or tableB.id
This query returns 0 results (but no syntax errors!)

I'm not a mysql expert, so I don't know if the "OR condition" is allowed, or if there is some kind of limitation in codeigniter engine.




Theme © iAndrew 2016 - Forum software by © MyBB