select of.off_karnet, of.off_int_info, of.off_stat_update_info, of.off_id,of.ter_id,of.off_status,of.pob_id, of.obj_id, of.off_obj_nazwa, of.off_pob_nazwa, of.reg_id, of.typ_id,of.off_cena_za_osobe,
pob.pob_gal_id, pob.pob_osoby_min, pob.pob_osoby_max, pob.pob_visible,
o.obj_wlasciciel,o.obj_adres,o.obj_kod,o.obj_miasto,o.obj_telefon, o.obj_fax,o.obj_kom, o.obj_email,o.obj_www, o.obj_visible
from pl_oferty_spec as of, pl_pobj as pob, pl_obj as o
where of.off_visible=1 and of.off_status in(0,2) and of.ter_id = 540 and of.reg_id in(1,2,3,4) and of.typ_id in(1,2,3,4)
and o.obj_visible=1 and pob.pob_visible=1 and of.pob_id=pob.pob_id and of.obj_id=o.obj_id order by o.obj_priorytet desc, of.obj_id desc limit ,