我的第一个查询应该返回一个结果。
$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
将两个查询与 INNER JOIN [MySQL Docs] 结合起来.
关于php - 我想在另一个使用 PHP 和 mysql 的查询中使用一个查询的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7023096/