我正在使用以下查询从数据库中检索项目列表

    $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包含DealerId

我想用diamondsList i-e diamondsList->dealer添加发牌人表。搜索后,我发现已使用JOIN,但不确定如何使用它从diamondList->dealerId获取经销商行

最佳答案

就像是 ...

SELECT diamondsList.*,
dealer.name
FROM diamondsList
JOIN dealer
on diamondsList.dealerid = dealer.dealerid
WHERE .....

关于php - 从另一张表加入一行到另一张表中的一行php mysql,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21831344/

10-15 18:04