Pretraga aranžmana

drop temporary table if exists TP; create temporary table TP ( #PRIMARY KEY (id), #INDEX temp__prid (id), INDEX temp__marketid (wpid), INDEX temp__price (bed,ext,chd,bedpricesfinal), INDEX temp__package (packageid,packagename) ) select pr.*,P.post_title ,idx.countryid,cnt.name countryname ,idx.cityid,cty.name cityname ,idx.regionid,rgn.name regionname ,idx.servicetypeid,sta.name servicetypename ,idx.generaltypeid,gta.name generaltypename from ( select pr.* from wpone_tourpricev2final pr where pr.wpid in(9187,9188,9190,9192,9199,9205,9227,9238,9241,9247,9249,9250,9253,9259,9262,9265,9266,9286,9296,9309,9310,9320,9327,9328,9339,9340,9349,9350,9352,9369,9370,9390,9391,9392,9393,9394,9395,9396,9397,9398,9404,9412,9424,9440,9444,9445,9449,9452,9466,9468,9486,9498,9515,9522,9524,9531,9533,9535,9536,9538,9539,9540,9547,9548,9550,9551,9557,9558,9559,9560,9561,9562,9563,9571,9576,9579,9587,9592,9596,24512,24514,24515,25793,29732,44889,44890,47289,50220,50913,54470,58705,59478,61653,71141,71142,71143,80041,86767,92369,94220,94915,96029,96059,96060,96061,96062,96471,96746,97056,97108,97139,97324) and (pr.validfrom is null or (validfrom>='2020-10-24')) and (pr.expires is null or (expires>='2020-10-24')) and pr.hotelduration=6 and pr.tourduration=7 and pr.departuredate='2019-12-29' and pr.bed+pr.ext=2 and pr.inf>=0 and pr.chd=0 ) pr left join 0Wjxn7YMR_posts P on pr.wpid=P.ID left join wpone_hotelindex idx on idx.ID=pr.wpid left join 0Wjxn7YMR_terms cnt on cnt.term_id=idx.countryid left join 0Wjxn7YMR_terms cty on cty.term_id=idx.cityid left join 0Wjxn7YMR_terms rgn on rgn.term_id=idx.regionid left join 0Wjxn7YMR_terms sta on sta.term_id=idx.servicetypeid left join 0Wjxn7YMR_terms gta on gta.term_id=idx.generaltypeid where P.post_status='publish' and idx.countryid='276' and idx.cityid='277' ;drop temporary table if exists TPORDER; create temporary table TPORDER select packageid temppackageid, wpid temppostid, min(bedpricesfinal) minprice from TP where bed=2 and ext=0 and chd=0 group by packageid,wpid;select tp.* from TP tp left join TPORDER tpo on tpo.temppostid=tp.wpid and tpo.temppackageid=tp.packageid order by tpo.minprice,tp.wpid,tp.bed,tp.ext,tp.bedpricesfinal,tp.ext,tp.chd,tp.min1,tp.min2,tp.min3,tp.min4 ;