SELECT
m.id_priority, b1.bank_name, p1.product_name, b2.bank_name, p2.product_name, b3.bank_name, p3.product_name
FROM matrix m
INNER JOIN products p1 ON m.product1 = p1.id_product
INNER JOIN products p2 ON m.product2 = p2.id_product
INNER JOIN products p3 ON m.product3 = p3.id_product
INNER JOIN banks b1 ON p1.id_bank = b1.id_bank
INNER JOIN banks b2 ON p2.id_bank = b2.id_bank
INNER JOIN banks b3 ON p3.id_bank = b3.id_bank
ORDER BY m.id_priority
$(window).scroll(function (event) {
var top = $(window).scrollTop();
if(top >= 20){
//show btn
} else {
//hide btn
}
});