SELECT TOP 50 cabin.name, cabin.id, cabin.units, cabin.phone, cabin.cabinOwner, cabin.cordes_zimmer ,cabin.first_pic_location, cabin.show_pics_nums, Cities.cordes, Cities.url, Cities.sub_area, cabin.settlement, cabin.zones, cabin.sales, cabin.max_guests, cabin.num_people_sleep, cabin.place_type, cabin.num_rooms,cabin.num_rates, cabin.price_min, cabin.price_min_wday, bfast, pricesMin.lmin_wend, zimer_type, categories, cabin.address FROM cabin
LEFT JOIN Cities ON (cabin.zones=Cities.name)
LEFT JOIN cabinCat ON cabin.id = cabinCat.idCabin
LEFT JOIN prices_z ON cabin.id = prices_z.idCabin
LEFT JOIN pricesMin ON cabin.id = pricesMin.idCabin
LEFT JOIN cabinUpdates ON cabin.id = cabinUpdates.idCabin
WHERE cabin.sales != '*' GROUP BY cabin.name, cabin.id, cabin.units, cabin.phone, cabin.cabinOwner, cabin.cordes_zimmer ,cabin.first_pic_location, cabin.show_pics_nums, Cities.cordes, Cities.url, Cities.sub_area, cabin.settlement, cabin.zones, cabin.sales, cabin.max_guests, cabin.num_people_sleep, cabin.place_type, cabin.num_rooms,cabin.num_rates, cabin.price_min, cabin.price_min_wday, bfast, pricesMin.lmin_wend, zimer_type, categories, cabin.address ORDER BY cabin.num_unavail DESC
Array
(
[0] => Array
(
[0] => 42000
[SQLSTATE] => 42000
[1] => 8127
[code] => 8127
[2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Column "cabin.num_unavail" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
[message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Column "cabin.num_unavail" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
)
[1] => Array
(
[0] => 42000
[SQLSTATE] => 42000
[1] => 16945
[code] => 16945
[2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]The cursor was not declared.
[message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]The cursor was not declared.
)
)