我正在使用以下查询来检索数据库中的项目列表
$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
答案 0 :(得分:1)
类似......
SELECT diamondsList.*,
dealer.name
FROM diamondsList
JOIN dealer
on diamondsList.dealerid = dealer.dealerid
WHERE .....