[英]Join a row from another table to row in another table php mysql
I am using following query for retrieving a list of items from database 我正在使用以下查询从数据库中检索项目列表
$statement = $conn->prepare('SELECT * FROM diamondsList WHERE price >= :minPrice AND price <= :maxPrice AND carat >= :minCarat AND carat <= :maxCarat AND cut IN(' . $cut . ') AND clarity IN ('.$clarity.') AND color IN ('. $color.') AND diamondsType IN (' . $type.') ');
diamondsList contains dealerId diamondsList包含DealerId
I want to add dealer table with diamondsList
ie diamondsList->dealer
. 我想补充的经销商表
diamondsList
即diamondsList->dealer
。 After searching i have found that JOIN is used but not sure How to use it to get dealer row from diamondList->dealerId
搜索后,我发现已使用JOIN,但不确定如何使用它从
diamondList->dealerId
获取经销商行
something like ... 就像是 ...
SELECT diamondsList.*,
dealer.name
FROM diamondsList
JOIN dealer
on diamondsList.dealerid = dealer.dealerid
WHERE .....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.