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

标签 php 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

将两个查询与 INNER JOIN [MySQL Docs] 结合起来.

关于php - 我想在另一个使用 PHP 和 mysql 的查询中使用一个查询的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7023096/

相关文章:

php - 如何在 OpenCart 中制作一个简单的模块?从 Wordpress 获取最新帖子并在 OpenCart 中显示的示例?

php - 如何在任何方法php中存储临时数据

mysql - 我可以将更新的结构导入 MySQL 表而不丢失其当前内容吗?

php - 如何使用php和mysql基于一个词从数据库中获取几乎相同的词

javascript - 使用远程数据库提前输入并动态加载下拉列表

php - php和mysql的进度条

php - jQuery PHP 在函数内传递值与实时点击?

sql - 在 MySQL 中存储图像

mysql - 如何使用 UNION ALL 计算两个查询

php - 你如何从ssh运行一个php文件?