Fixed database query for projects