tags:

views:

46

answers:

1

Hello,

How to write this SQL statement in Active Record:

$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 . '"');

Please help. Thanks.

+1  A: 
$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();

If your selected table fields are not ambiguous you can drop shortcutting like 'AS a, u'...

L.I.A. Ant.