1

我以前从未使用过子查询,并且无法SELECTUPDATE.

我在这里使用并且想坚持使用Active Record 类以保持一致性,但我可以使用原始 SQL。

这是我使用 AR 类的最后一次尝试:

$this->db->select('locations.id, locations.name');
$this->db->join('locations','location_relationships.id = locations.id');
$sub = $this->db->_compile_select();

$this->db->_reset_select();

$this->db->where('id', $location_id);
$this->db->where('group_id', $team_id);
$query = $this->db->update('location_relationships', $data);

基本上,我正在更新此location_relationships表中的一个值,当发生这种情况时,我想选择同一个表中的一些关联单元格和另一个(locations)。所以JOINSELECT子查询中也有一个。

任何帮助,将不胜感激!

4

1 回答 1

0

放第UPDATE一个,然后做SELECT

然后你可以摆脱以下:$sub = $this->db->_compile_select(); $this->db->_reset_select();

于 2012-05-05T19:08:07.623 回答