How to better perform a query split into subqueries in PHP
Quickly get into the habit of writing your queries with some kind of formatting, proper joins, and with properly qualified column names. It makes it much easier to understand. E.g.:

SELECT t.id
     , t.uid
  FROM tracks t
  JOIN users u
    ON u.idu = t.uid
 WHERE t.time &gt; CURDATE() - INTERVAL 1 YEAR
   AND u.public &gt; 0 
 ORDER
    BY RAND() 
 LIMIT 10