Looks OK, beautiful, fine, etcetera. But it does not help you to find N.
In two ways:
1) If it was to help you find N you would write N = m2 g / M , not m2 g / N = M
2) Whichever way you write it, there still is this little problem that you don't know m2. No wonder, because that was what the original exercise was asking for.
Quoting light grav: m1 is not going up and it is not going down. It is not accelerating in the vertical direction, even though gravity is pulling down with a force m1 g. The acceleration is zero.
The acceleration can only be zero if the table exercises a normal force N that is equal and opposite to m1 g.
In other words:
m1 g + N = 0
The usual choice of coordinates is y+ = up, which means that m1 g is pointing in the negative y direction. Something like m1 kg x -9.81 m/s2:
m1 kg x -9.81 m/s2 + N = 0 ##\Leftrightarrow## N = m1 * 9.81 kgm/s2.
So by now, we can assume N is really a known thing. Right ?
Back to your thingy and now rewrite it so that it helps you find m2 !