How to fasten one pipe to another under sink
Both the pipe connections on the vertical pipe run in your picture (the one with the nut and the threaded one which is missing the nut) are designed as slip-joint connections. They utilize a rubber or plastic slip-joint washer that squeezes down on the inserted pipe when the slip-joint nut is tightened.

The assembly coming down from the sink is called a pop-up drain assembly and it has a 1 1/4" tailpiece pipe that you cannot see in your picture because it is inserted entirely into the 1 1/2" slip-joint extension which, by the way, is the piece that is missing its slip-joint nut).

You will need to get a couple parts from the plumbing shop: (1) 1 1/2" x 1 1/4" slip-joint nut; and (1) 1 1/2" x 1 1/4" slip-joint washer (rubber or plastic, don't matter)

Then you need to do exactly this:


remove the trap u-bend at the bottom
remove the 1 1/2" slip-joint extension and cut it down 1"
slide an 1 1/2" x 1 1/4" slip-joint nut up onto the 1 1/4" tailpiece, followed by an 1 1/2" x 1 1/4" slip joint washer
slide the (now 1" shorter) 1 1/2" slip-joint extension up onto the 1 1/4" tailpiece and hand tighten the nut and washer, from the previous step, to the threaded top of it
slide the trap u-bend back up into place
wiggle everything about until it's straight and clean
tighten all slip-joint nuts with a wrench, not too tight but more than hand-tight.


It should look something like this when you are done: