I'm trying to get pairs of matching columns by joining the table Customer with the already joined table of BuyVehicle & Vehicle which I've given the alias 't'. How is p1.SSN and I assume p2.SSN will follow an unknown column if I've assigned the alias in the first line?
SELECT p1.SSN, p2.SSN FROM Customer AS p1, Customer AS p2
INNER JOIN (SELECT BVSSN, BVVin, Vin FROM CarPurchase INNER JOIN Car ON BVVin = Vin)
AS t ON p1.SSN = BVSSN & p2.SSN = BVSSN
WHERE p1.SSN < p2.SSN AND //matching columns comparisons yet to be added;
ERROR 1054 (42S22): Unknown column 'p1.SSN' in 'on clause'