我正在尝试使用Zend Framework构建SQL查询。这是我的SQL查询语句:
SELECT of.order_Id, of.subtotal, of.status, c.name
FROM order_form of, customer c
WHERE c.customer_Id = of.customer_Id
但是,当我尝试在Zend Framework中实现它时,会显示一条错误消息。这是我使用Zend Framework的查询语句。
$query = $db->select()
->from(array('c' => 'customer'), 'name')
->where('c.customer_Id = ?', $customer_Id)
->join('order_form', 'order_form.customer_Id = customer.customer_Id', array('order_Id', 'subtotal', 'status'))
->order("order_form.order_Id ASC");
答案 0 :(得分:0)
我的部分有错误。只需在customer.customer_Id
子句
c.customer_Id
更改为join
即可
$query = $db->select()
->from(array('c' => 'customer'), 'name')
->where('c.customer_Id = ?', $customer_Id)
->join('order_form', 'order_form.customer_Id = c.customer_Id', array('order_Id', 'subtotal', 'status'))
->order("order_form.order_Id ASC");
很抱歉给您带来不便。