在mysql中选择两个独立的表 [英] Select two independent tables in mysql
本文介绍了在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.
如何从两个独立的表中选择两个表product_name和price?
How can I select two table product_name, price from two independent tables?
推荐答案
听起来您想使用inner join
或outer join
.
http://en.wikipedia.org/wiki/Join_(SQL)
或者可能是union
:
http://en.wikipedia.org/wiki/Union_(SQL)# UNION_operator
这篇关于在mysql中选择两个独立的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文