We present results for the leading order QCD correction to the anomalous magnetic moment of the muon including the first two generations of quarks as dynamical degrees of freedom. Several light quark masses are examined in order to yield a controlled extrapolation to the physical pion mass. We analyse ensembles for three different lattice spacings and several volumes in order to investigate lattice artefacts and finite-size effects, respectively. We also provide preliminary results for this quantity for two flavours of mass-degenerate quarks at the physical value of the pion mass.