SQL Error


Code error: 42S22.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'relevance' in 'order clause' (SQL: select `posts`.`id`, `country_code`, `category_id`, `post_type_id`, `title`, `posts`.`price`, `city_id`, `featured`, `posts`.`created_at`, `reviewed`, `verified_email`, `verified_phone`, (posts.price * 1) AS calculatedPrice, tPackage.lft, (6371 * 2 * ATAN2(SQRT(SIN(RADIANS(ST_Y(POINT(57.77, 22.93)) - ST_Y(POINT(lon, lat)))/2) * SIN(RADIANS(ST_Y(POINT(57.77, 22.93)) - ST_Y(POINT(lon, lat)))/2) + COS(RADIANS(ST_Y(POINT(lon, lat)))) * COS(RADIANS(ST_Y(POINT(57.77, 22.93)))) * SIN(RADIANS(ST_X(POINT(57.77, 22.93)) - ST_X(POINT(lon, lat)))/2) * SIN(RADIANS(ST_X(POINT(57.77, 22.93)) - ST_X(POINT(lon, lat)))/2)), SQRT(1-SIN(RADIANS(ST_Y(POINT(57.77, 22.93)) - ST_Y(POINT(lon, lat)))/2) * SIN(RADIANS(ST_Y(POINT(57.77, 22.93)) - ST_Y(POINT(lon, lat)))/2) + COS(RADIANS(ST_Y(POINT(lon, lat)))) * COS(RADIANS(ST_Y(POINT(57.77, 22.93)))) * SIN(RADIANS(ST_X(POINT(57.77, 22.93)) - ST_X(POINT(lon, lat)))/2) * SIN(RADIANS(ST_X(POINT(57.77, 22.93)) - ST_X(POINT(lon, lat)))/2)))) AS distance from `posts` left join (select MAX(lp.id) as lpId, `lp`.`post_id` from `payments` as `lp` where `lp`.`active` = 1 group by `lp`.`post_id`) as `tmpLp` on `tmpLp`.`post_id` = `posts`.`id` and `featured` = 1 left join `payments` as `latestPayment` on `latestPayment`.`id` = `tmpLp`.`lpId` left join `packages` as `tPackage` on `tPackage`.`id` = `latestPayment`.`package_id` left join `packages` as `package` on `package`.`translation_of` = `tPackage`.`id` where exists (select * from `categories` where `posts`.`category_id` = `categories`.`translation_of` and `translation_lang` = ar and `active` = 1) and exists (select * from `post_types` where `posts`.`post_type_id` = `post_types`.`translation_of` and `translation_lang` = ar and `active` = 1) and exists (select * from `cities` where `posts`.`city_id` = `cities`.`id` and `active` = 1) and `country_code` = OM and (`verified_email` = 1 and `verified_phone` = 1) and `archived` = 0 and `verified_email` = 1 and `verified_phone` = 1 group by posts.id having distance <= 50 order by relevance DESC, distance ASC, tPackage.lft DESC, posts.created_at DESC limit 12 offset 0)