Drain pipe under sink separated, how to fix?
It looks like the tail corroded away, unscrew the nut and take the short pice of pipe to a plumbing store or even a big box and replace both of them.  I would probably replace the  trap also it may break when you start moving it , a trap and the tail piece nuts seals and all will probably be under 20$ for plastic maybe 15$ .For a complete kit in a bag.