Incompatibility with Mysql 5.7(Expression #1 of ORDER BY clause is not in SELECT list) Incompatibility with Mysql 5.7(Expression #1 of ORDER BY clause is not in SELECT list) angularjs angularjs

Incompatibility with Mysql 5.7(Expression #1 of ORDER BY clause is not in SELECT list)


I have find the answer for my question.Actually mysql 5.7 contains 'ONLY_FULL_GROUP_BY' in sql mode.So we can't perform orderby in the element that is not in select list.we have to change it from

'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 

into

'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

We can done this by executing the following queries

SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'


ORDER BY column should be column listed in the SELECT list

Add c.level_depth in your select list

Try:

SELECT DISTINCT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite, c.level_depth    FROM `pj_category_shop` cs, `pj_category` c    INNER JOIN `pj_category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = 1 AND cl.id_shop = 2 )    WHERE (c.`active` = 1 OR c.`id_category` = 2)    AND cs.`id_category` = c.`id_category` AND cs.`id_shop` = 2    AND c.`id_category` != 1     AND `level_depth` <= 2    AND c.id_category IN (SELECT id_category FROM `pj_category_group` WHERE `id_group` IN (3))    ORDER BY c.`level_depth` ASC, cl.`name` ASC;


Sql Feature Order by is as the name suggests used to order the Selected Columns on the basis of the Column mentioned in the below Syntax :Order by Column_Name ASC/DESC

So if you don't add the column using which you have decided to retrieve order set of data in the select clause you will get this error.