1

Here is a working query

$connection = $this->_objectManager->create('\Magento\Framework\App\ResourceConnection');
      $conn = $connection->getConnection();
      $select = $conn->select()
          ->from(
              ['o' => 'sales_order']
          )
          ->where('o.created_at>=?', $place_date);
      $data = $conn->fetchAll($select);

Now i want to Left join with table sales_order_address

ON sales_order_address.parent_id = sales_order.entity_id

and want to select sales_order_address.street too.

4

The join Method should take the table as the first and the on statement as the second attribute. So something like this should work:

$connection = $this->_objectManager->create('\Magento\Framework\App\ResourceConnection');
      $conn = $connection->getConnection();
      $select = $conn->select()
          ->from(
              ['o' => 'sales_order']
          )
          ->join(
            ['soa' => 'sales_order_address'],
            'soa.parent_id=o.entity_id'
          )
          ->where('o.created_at>=?', $place_date);
      $data = $conn->fetchAll($select);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.