我想使用PHP和mysql在另一个查询查询的结果


I would like to use the result of a query in another query using PHP and mysql

我的第一个查询应该返回一个结果。

$query="select idtechnic from technic where idname='$technic' and setname='$set' and number='$number'";
我想在第二个查询中使用上面查询的结果:
$result=mysql_query($query);
$row1=mysql_fetch_assoc($result)
$query1="select idtechnic, move from moves where idtechnic='$row1[0]' order by idmoves";

我也尝试了mysql_fetch_array($query)mysql_result($query, 1)

SELECT moves.idtechnic, moves.move 
FROM moves
INNER JOIN technic
        ON technic.idtechnic=moves.idtechnic
WHERE technic.idname='$technic' 
  AND technic.setname='$set' 
  AND technic.number='$number'
ORDER BY moves.idmoves

mysql_fetch_assoc获取一个关联数组(也就是hash或map)。因此,您的idtechnic值位于$row1['idtechnic']中。但是,您最好像@cularis建议的那样将查询组合起来,因为它将产生更快,更可读的代码。