Welcome Guest, Not a member yet? Register   Sign In
how can i write this query
#3

(This post was last modified: 11-05-2014, 08:02 AM by Rufnex.)

for one machting filed you can us this statement

Code:
delete r1
    from role_perms r1, role_perms r2
where
    r1.duplicate= r2.duplicate
and
    r1.id > r2.id

$this->db->query('delete r1 from role_perms r1, role_perms r2 where r1.duplicate = r2.duplicate and r1.id > r2.id');

It deletes all duplicate rows based on the field 'duplicate' and leaving the row with the lowest id. Test it before you use it in production Wink

If you need more matches look at this usefull post:

http://stackoverflow.com/questions/25948...-sql-table

Reply


Messages In This Thread
how can i write this query - by rajneeshgobin - 11-04-2014, 10:42 PM
RE: how can i write this query - by Jeroen - 11-05-2014, 05:17 AM
RE: how can i write this query - by Rufnex - 11-05-2014, 07:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB