Welcome Guest, Not a member yet? Register   Sign In
Active Record + Join SQL Problem
#7

[eluser]meigwilym[/eluser]
Not sure but you may want to try the following. I've put the SELECT into one line (you may have needed a comma after 'table2.*') added a FROM and given the ORDER BY clause a table reference.

Code:
$this->db->select("table1.*, table2.*, table3.*, table4.*");

$this->db->from('table1');

$this->db->join('table2', 'table1.id = table2.id', 'left');
$this->db->join('table3', 'table1.id = table3.id', 'left');
$this->db->join('table4', 'table1.id = table4.id', 'left');
$this->db->where('table1.id', $id);
$this->db->order_by('table1.timestamp desc');
$this->db->limit(15);

$this->db->get()

Also, try the raw SQL version, just to see.

Code:
$sql = "SELECT table1.*, table2.*, table3.*, table4.* FROM table1 LEFT INNER JOIN table2 ON table1id = table2.id LEFT INNER JOIN table3 ON table2.id = table3.id LEFT INNER JOIN table4 ON table3.id = table4.id ORDER BY table1.timestamp DESC LIMIT 15"

$query = $this->db->query();

Whatever you get, there should be an SQL error if there's anything wrong with it.

Cheers,

Mei


Messages In This Thread
Active Record + Join SQL Problem - by El Forum - 02-18-2009, 06:26 PM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 02:19 AM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 03:49 AM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 06:03 AM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 07:13 AM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 01:49 PM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 02:21 PM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 02:26 PM
Active Record + Join SQL Problem - by El Forum - 02-19-2009, 02:52 PM
Active Record + Join SQL Problem - by El Forum - 02-20-2009, 08:51 AM
Active Record + Join SQL Problem - by El Forum - 02-28-2009, 03:50 PM
Active Record + Join SQL Problem - by El Forum - 02-28-2009, 05:01 PM
Active Record + Join SQL Problem - by El Forum - 02-28-2009, 05:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB