Check if the query contains joins and get join parameters