How to write a self join query in drupal 7 using db_select
A query using db_select is a lot slower than a 'vanilla' db_query call...for a query as simple as the one you're doing just run it through db_query:

$query = db_query('SELECT * FROM msg where sender = receiver');