我有三个非常简单的查询,我相信它们可以在一个查询中完成,但我无法弄清楚。以下是查询:
$idSQL = "SELECT website_id FROM websites WHERE website_url = :webURL LIMIT 1
$featureSQL = "SELECT feature_id FROM feature_website WHERE website_id = :webID";
$sql = "SELECT feature_name, feature_start, feature_end, feature_headline, feature_text, feature_photoHor, feature_photoVert, feature_photoSquare FROM features WHERE feature_id = :featID";
这给了我预期的输出:
因此,我尝试将查询(可能使用不正确的联接)组合成:
$sql = "SELECT f.feature_name, f.feature_start, f.feature_end, f.feature_headline, f.feature_text, f.feature_photoHor, f.feature_photoVert, f.feature_photoSquare FROM features LEFT JOIN feature_website fw ON f.feature_id = fw.feature_id LEFT JOIN websites w ON fw.website_id = w.website_id AND w.website_url = :webURL";
我错过了什么?