Tested on QGIS 2.18 and QGIS 3.4
I can suggest using a
"Virtual Layer" through
Layer > Add Layer > Add/Edit Virtual Layer...
Let's assume we have eight features in
"school" (blue squares) and five in
"tower" (orange circles) accordingly, see image below.
With the following Query, it is possible to achieve the result
SELECT s.Name AS SName, t.Name AS TName,
ROUND(MIN(ST_Distance(s.geometry, t.geometry)),2) AS distance,
s.id || '_' || t.id AS uniqueid
FROM school AS s, tower AS t
GROUP BY s.Name
ORDER BY distance DESC
The output Virtual Layer will generate shortest lines between schools and towers including the following attributes 'school name', 'closest tower name', 'distance to the closest tower' and 'unique id'.