i ahve written one query in my sql and i want to write it in drupal7 standards

select erid,cnetuid from cnetusers c 
inner join eregister_master m on (c.cnetuid = m.tvalue_id and m.type = 'cnetusers') 
or (c.bu = m.tvalue_id and m.type = 'bu') or (c.sbu = m.tvalue_id and m.type = 'sbu')
inner join field_data_field_date_of_issue f on f.entity_id = m.nid and f.entity_type = 'node' 
and f.bundle = 'e_register' 
where m.processed = 0 and f.field_date_of_issue_value <= 1347494400 ;