我有两张桌子: 文章 - 行业标准 如何将此查询转换为zend Db查询连接
$ SQL =“
SELECT article
。*,sub_categories
。name_arabic
AS sub_category_name_arabic
,sub_categories
。name_english
AS sub_category_name_english
,{{ 1}}。article
AS sub_category_id
FROM sub_categories_id
LEFT JOIN article
点击sub_categories
。article
= sub_category_id
。sub_categories
在id
。article
= 1
“;
请帮助
谢谢
答案 0 :(得分:0)
这应该可以解决问题:
$db->select()
->from('article', array('*', 'sub_categories_id' => 'sub_category_id')
->joinLeft(
'sub_categories',
'article.sub_category_id = sub_categories.id',
array('sub_category_name_arabic' => 'name_arabic', 'sub_category_name_english' => 'name_english'))
->where('article.active = 1');