There are two SQL queries. The first is performed without problems:
SELECT DISTINCT self.*, (SELECT COUNT(*) FROM `ps_orders` WHERE self.`id_customer` != 'NULL' AND `id_customer` = self.`id_customer`) AS orders_total FROM `ps_module_actionssubscription` AS self LIMIT 0,20; And on the second MySQL query, I swear at Error Code: 1054. Unknown column 'orders_total' in 'where clause' :
SELECT DISTINCT self.*, (SELECT COUNT(*) FROM `ps_orders` WHERE self.`id_customer` != 'NULL' AND `id_customer` = self.`id_customer`) AS orders_total FROM `ps_module_actionssubscription` AS self WHERE orders_total > 5 LIMIT 0,20; Where is the error in the second request ?? How to write it down correctly so that it returns only results on the WHERE condition ??