In the execution sequence of mysql statements, is the select statement executed first or the group by statement executed first? Is the select statement executed first or the having clause executed first ?? Mysql> select (@ a: = empid) a, heyf_t10. * from heyf_t10; www.2cto.com + --- + ------- + -------- + | a | empid | deptid | salary | + --- + ------- + -------- + | 1 | 1 | 10 | 5500 | 2 | 2 | 10 | 4500 | 3 | 3 | 20 | 1900 | 4 | 4 | 20 | 4800 | 5 | 5 | 40 | 6500 | 6 | 6 | 40 | 14500 | 7 | 7 | 40 | 44500 | 8 | 8 | 50 | 6500 | 9 | 9 | 50 | 7500 | + --- + ------- + -------- + 9 Rows in set mysql> select (@ a: = empid) a, heyf_t10. * from heyf_t10 having @ a = 5; why is the result set Empty when the second query condition of Empty set is having @ a = 5 ?? Www.2cto.com --------------------------------------------------------------- mysql> select (@ a: = empid) a, heyf_t10. * from heyf_t10 having empid = 5; + --- + ------- + -------- + | a | empid | deptid | salary | + --- + ------- + -------- + | 5 | 5 | 40 | 6500 | + --- + ------- + -------- + 1 row in set why can I normally return data records when having empid = 5 is used? The summary cannot be in group, having and order by clauses are followed BY user Variables