Distance matrix for mysql, based on previous solution for haversine distance calculation
问题 This question is self-answered to help people that need to create distance matrix in MySQL, which supports queries such as "select id2 from Distances where id1=10 and type1=0 and type2=1 and distance<10" which would find objects of type 1 in vicinity of 10 from object 10 of type 0. The code assumes table structure similar to one described in Mysql Haversine distance calculation If you ever find yourself in need of a distance matrix in mysql, here's a View definition for it: select o1.object