Magento の比較的新しいユーザーであり、SQL のさらに新しいユーザーとして、この質問はばかげたものになる可能性があります。
Magento API を使用して SQL クエリを作成するのに非常に苦労しています。API に変換しようとしているクエリは、すぐ下にあります。
SELECT b.product_id, e.item_nr
FROM mag1catalog_product_flat_1 AS 'e'
RIGHT OUTER JOIN
mag1personal_order AS 'b'
ON b.product_id = e.item_nr
WHERE e.item_nr is null or e.erp_item_nr = '';
Magento コレクション クエリと結果の SQL に関して、これまでに得たものは以下のとおりです。
public function importCatalog() {
$catalogCollect = Mage::getModel('catalog/product')->getCollection();
$catalogCollect->addAttributeToFilter('item_nr');
$orderflyCollect->addAttributeToFilter('b.product_id');
$catalogCollect->getSelect()->joinRight(array('b'=>'mag1personal_order'), 'b.product_id = e.item_nr', 'e.item_nr');
echo $catalogCollect->getSelect();
SQL クエリ:
SELECT 1 AS `status`, `e`.`entity_id`, `e`.`type_id`, `e`.`attribute_set_id`, `e`.`item_nr`, `e`.`item_nr` FROM `mag1catalog_product_flat_1` AS `e` RIGHT JOIN `mag1personal_order` AS `b` ON b.product_id = e.item_nr WHERE (e.item_nr = '')
以下にいくつか質問があります。
1) SQL クエリの先頭にある「1 AS」はどこから来て、どうすればそれを残すことができますか?
2)どこstatus
で , e
. entity_id
、e
。type_id
、e
。attribute_set_id
、e
。item_nr
、およびe
。item_nr
から来る?私はちょうどフィルタリングしようとしたと思いましたe
。item_nr
および「b.product_id」? 「b.product_id」さえありません。
3) RIGHT/LEFT JOIN だけでなく、RIGHT/LEFT OUTER/INNER JOIN を指定するにはどうすればよいですか?
これらの助けをいただければ幸いです。