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 = '534' and status = 'active' and comcontact.loginid = '534' ORDER BY lids.lid LIMIT -39,20 ;