http://www.nolo.com/legal-encyclopedia/what-is-lien-priority.html
先抛去tax lien,judgment lien不管,只说mortgage lien。
a house has 300K first mortgage, 100K second mortgage. 300K loan has priorty over second mortgage. First / second means timewise who is first/second.
If first mortgage bank starts the foreclosure, sells for 350K, first bank gets 300K, second bank get 50K. both liens are paid off. The second bank can sue the previous owner for deficiency. Only in this case first lien wipes off "everything". Or first lien wipes off junior liens.
If second mortgage starts the foreclosure, the foreclosure of second mortgage does not wipe off superior mortgage lien. In that case you as a buyer should only pay up to 100K for the second lien, because the first lien is still attached to the house.
Usually tax lien is superior to all mortgage lien. So you must pay tax lien even after you bought a house based on first mortgage lien foreclosure.