在 mysql 中选择两个独立的表


Select two independent tables in mysql

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

这是我的代码,我想从数据库中获取两个表,即"草药"和"水果"并更新我的购物车。

如何从两个独立的表中选择两个表product_name,价格?

听起来你想使用inner joinouter join

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

或者可能是union

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