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