I am also surprised that 2 queries are faster than 1, but not so surprised that you have poor performance overall. You see, if the columns used in the WHERE clause are not indexed then you are forcing a table scan.
If you use EXPLAIN then you will see just what is happening in your particular case.
Now if the columns used in the where clause are also indexed then the server can avoid a table scan. So add indexes to TeamID (probably you already have that) and EndDate. Then run EXPLAIN again and see the difference.
With EXPLAIN what you are looking for is a) anything that says 'table scan', b) the number of rows involved in temp tables and intermediate resultsets. You also want to check that indexes are actually being used, and in the most efficient order.
An alternative to your 2 queries is as follows:
if ($year != "") {
$vsql1 = "SELECT PlayerID from stats WHERE TeamID='$tID' AND EndDate='$year'";
}
else {
$vsql1 = "SELECT PlayerID from stats WHERE TeamID='$tID' AND EndDate='$global_enddate' AND Hidden='0'";
}
$vsql2 = "SELECT PlayerID, Firstname, Lastname, Pos, Pos2, Birth, Birthplace, Length, Weight,
Rookie, Shoots, Motherclub, NationID, Contract, Caphit, Injured, Injuredinfo FROM player
WHERE PlayerID IN ($vsql1) ORDER BY Pos ASC, Lastname ASC";
Here we are doing the same thing without 2 trip to the database.
But that does not solve your extra field problem. For that you can use a sub query in a different way
if ($year != "") {
$vsql1 = "SELECT PlayerID, Loan from stats WHERE TeamID='$tID' AND EndDate='$year'";
}
else {
$vsql1 = "SELECT PlayerID, Loan from stats WHERE TeamID='$tID' AND EndDate='$global_enddate' AND Hidden='0'";
}
$vsql2 = "SELECT PlayerID, Loan, Firstname, Lastname, Pos, Pos2, Birth, Birthplace, Length, Weight,
Rookie, Shoots, Motherclub, NationID, Contract, Caphit, Injured, Injuredinfo FROM player INNER JOIN $vsql1 AS t1 USING(PlayerID) ORDER BY Pos ASC, Lastname ASC";
Here I am using the $vsql1 as a scalar or table-type sub query. It will be executes first and then joined to the outer query. Predicting performance with this type of query is dificult so suck it and see is all I can recommend.
In all cases, add the indexes to columns frequently used in where clauses.