[eluser]callumd[/eluser]
Hi There,
Having trouble replicating a query using Active Record.
Here's the SQL (this works in MySQL):
Code:
SELECT project_name, task_name, urgency
FROM projects, tasks, urgency
WHERE tasks.project_id = projects.project_id AND tasks.urgency_id = urgency.urgency_id;
This doesn't work:
Code:
$this->db->select('project_name, task_name, urgency');
$this->db->where('tasks.project_id', 'projects.project_id');
$this->db->where('tasks.urgency_id', 'urgency.urgency_id');
$this->db->from('tasks, projects, urgency');
$query = $this->db->get();
The SQL it produces is close, but still malformed, hence not working:
Code:
SELECT `project_name`, `task_name`, `urgency` FROM (`tasks`, `projects`, `urgency`) WHERE `tasks`.`project_id` = 'projects.project_id' AND `tasks`.`urgency_id` = 'urgency.urgency_id'
Help! Thanks.