SELECT * from commercial01 left join commercial02 using(comid) left join lids on (commercial01.comid = lids.propid and lids.type='com') left join comcontact on (commercial01.comid = comcontact.comid and comcontact.ctype='1') where commercial01.loginid = '46361' and status = 'active' and comcontact.loginid = '46361' ORDER BY lids.lid LIMIT -27,20 ;