i have used the following query to select rows from tables.
Table 1:
id description status add_date topicid
1 xyz 0 22-3-13 5
2 pqr 0 21-3-13 5
3 abc 0 20-3-13 5
4 sdd 0 22-3-13 5
Table2:
id otherid
1 2
2 3
This query gives me all the record from table1 but i want to select those record which is not in table2.
like table1 'id' not present in table2 'otherid'.
In my case want to select record from table1 for id 1 and 4.because which is not present in table2 as 'otherid'.
$topicid = 5;
$q =$this->db->select(array(
't1.id as id',
't1.description',
't1.topicid',
't1.add_date'))
->from('table1 AS t1')
->where('t1.topicid',$topicid)
->where('t1.status',0)
->order_by('t1.add_date DESC)->get();