dream890110 2013-12-15 09:06
浏览 9
已采纳

在mysql中选择两个独立的表[关闭]

$results = $mysqli->query("SELECT product_name,price FROM herbs an WHERE product_code='$product_code' LIMIT 1");
    $obj = $results->fetch_object();

This is my code I want to get the two table form the database which is "herbs" and "fruits" and update my shopping cart.

How can I select two table product_name, price from two independent tables?

  • 写回答

1条回答 默认 最新

  • duanfengtuo6012 2013-12-15 09:09
    关注

    It sounds like you want to use either an inner join or an outer join.

    http://en.wikipedia.org/wiki/Join_(SQL)

    Or possibly a union:

    http://en.wikipedia.org/wiki/Union_(SQL)#UNION_operator

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

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line