dsxay48646 2013-02-28 03:33
浏览 11
已采纳

在表之间加入

I have a little trouble with a query.

I have this DB structure

PROCESSES process_id process_name

ITENS item_id item_process_id item_name

FILES file_id file_item_id file_name

I run this query to obtain Process ID:

$result = mysql_query("SELECT * FROM processes WHERE process_id='$process_id'");
$row = mysql_fetch_array($result, MYSQL_BOTH);
$process_id = $row['process_id'];

Put this ID in a LOOP to obtain all Itens from table:

$query="SELECT * FROM itens WHERE item_process_id='$process_id'";
$result = mysql_query($query) or die(mysql_error());
$num = mysql_numrows($result);

And call Item name into a LOOP

Problem is when i try to call "file_name" from FILES table. I have tried with a LEFT JOIN to table but with no success. "file_name" variable is blank

Can anyone help me to understand how solve this?

TKS

  • 写回答

1条回答 默认 最新

  • duanhuan6336 2013-02-28 03:52
    关注

    Try LEFT JOIN files ON file_id = file_item_id

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度