You get the values just like you have used the values in join, by prefixing them with the correct table name. You can also use shorter names which makes it a bit clearer like
Code:
select u.user_id from users u
(not sure if that's the format for mysql)
For looping through the resultset I would use while but I guess something else works just fine too.