如何在CodeIgniter的Active Record中编写此SQL语句

时间:2010-06-10 15:12:16

标签: codeigniter

如何在Active Record中编写此SQL语句:

$this->db->query('SELECT a.slogan, a.brief, u.id, u.name FROM example_tbl AS a, users AS u WHERE u.user_id = "' . USER_ID . '"');

请帮忙。感谢。

1 个答案:

答案 0 :(得分:1)

$this->db->select('a.slogan, a.brief, u.id, u.name')->where('u.user_id', USER_ID)->get('example_tbl AS a, users AS u')->result();

如果您选择的表格字段不明确,您可以删除类似'AS a,u'的快捷方式......