Programming education has become essential in primary schools, yet students' perceptions vary significantly across different achievement levels. While teacher support is crucial for learning, little is known about how it influences students' attitudes and flow experience across different achievement groups in programming education. This study examined the interrelationships among perceived teacher support, students' attitudes, and flow experience in programming learning across different achievement levels. Data were collected through surveys from 549 students across 43 Hong Kong primary schools. Students were categorised into three groups based on their programming achievement levels: above-average, average, and below-average. A multi-group mediation analysis was conducted to examine the relationships between variables. The above-average group showed significantly more positive perceptions across all variables than other groups. Students’ attitudes mediated the relationship between perceived teacher support and flow experience differently across achievement groups. The findings highlight the importance of differentiated teacher support strategies across achievement tiers and suggest that fostering positive attitudes towards programming is crucial for all achievement levels, particularly through enhancing the perceived usefulness of programming. Copyright © 2025 Elsevier Ltd. All rights are reserved, including those for text and data mining, AI training, and similar technologies.