I'm putting together a league script. When someone registers for a league they choose from a list of available teams in a drop down field.
The problem i'm having is that I'm getting this error message when there are more than one fields.
"Subquery returns more than 1 row"
here's the script:
//List available teams
$query_chamoline = "SELECT * FROM MLB WHERE `team`<>(SELECT `team` FROM leaguemembers WHERE `leagueid`=\"$lid\" AND `active`='Y') ORDER BY `team` ASC";
$chamoline = mysql_query($query_chamoline) or die(mysql_error());
$row_chamoline = mysql_fetch_assoc($chamoline);
$totalRows_chamoline = mysql_num_rows($chamoline);
<select id="team">
<option value="">Select Available Team</option>
<?php do { ?>
<?php
$tname=$row_chamoline['team'];
if($totalRows_chamoline>0)
{?>
<option value="<?php echo $tname ?>"><?php echo $tname ?></option><?php }} while ($row_chamoline = mysql_fetch_assoc($chamoline)); ?>
</select>
I'm selecting from the total list of teams in the MLB table that doesn't match the teams picked by other members in the leaguemembers table.
This change will stop the error, but not the logic error (if it exists)
$query_chamoline = "SELECT * FROM MLB WHERE `team`<>(SELECT TOP 1 `team` FROM leaguemembers WHERE `leagueid`=\"$lid\" AND `active`='Y') ORDER BY `team` ASC";
looking at his answer I expect Ass3mbler is right.