Simplified SQL queries in sites.php