Welcome Guest, Not a member yet? Register   Sign In
Join two tables with two or three same field
#3

[eluser]Anil3a[/eluser]
Hello i want to retrieve data from one table comparing with another table. Its like ..... selecting * from TABLE_ONE .... but not the rows that are .... TABLE_ONE_ID = TABLE_TWO_ID.

The TABLE_ONE has ids that are in TABLE_TWO but TABLE_TWO doesn't have ids that are in TABLE_ONE.

I tried this one but did not worked..
Code:
SELECT * FROM gift WHERE gift.gift_id NOT IN (select * from trans where trans_id = $trans_id) ORDER BY gift_id ASC');

where $trans_id is an array of ids that are in trans.

Also tried this one but it does not worked too.
Code:
$this->db->select('*');
$this->db->from('gift');
$this->db->join('trans', 'trans.trans_id = gift.gift_id');
$query = $this->db->where_not_in('gift_id', $trans_ids);


Messages In This Thread
Join two tables with two or three same field - by El Forum - 05-15-2012, 10:14 PM
Join two tables with two or three same field - by El Forum - 05-15-2012, 11:04 PM
Join two tables with two or three same field - by El Forum - 05-17-2012, 02:54 AM
Join two tables with two or three same field - by El Forum - 05-17-2012, 09:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB