I have taken a course in regression analysis. I learned that the equation $\beta =(X'X)^{-1}X'y$ can be used to find the weights in a linear model.
When learning about GLMs, I came across this formula that can be used when $(X'X)$ is not invertible while $XX'$ is.
$$\beta = X'(XX')^{-1}y$$
For example, if the generalized linear model is $y(x_1,x_2) = b_0 +b_1x_1+b_2x_2+b_3x_1x_2+b_4x_1^2+b_5x_2^2$, and there are, say, four data points, then there would be correlation between the columns and so we have to use the "right inverse method".
My question is, where did the equation $\beta = X'(XX')^{-1}y$ come from? I tried searching up the derivation, but could not find anything (which is why I could not come up with a nice title for this post; I don't know what keywords to use). I suspect it would be by performing partial derivatives, as in the usual $\beta =(X'X)^{-1}X'y$ equation, but I cannot see how it works.