我现在的SQL是:MySQL的左连接,其中连接表是空
SELECT * FROM `node`
LEFT JOIN `field_data_field_area_of_study_category`
ON `field_data_field_area_of_study_category`.`entity_id` = `node`.`nid`
WHERE `node`.`type` = 'area_of_study'
GROUP BY `node`.`nid`
现在,使其工作,我在列运行foreach
环路is_null()
。
我试图在SQL查询中模拟is_null()
检查。
感谢您的阅读。
编辑 这是运行is_null()
foreach循环。我认为更好的方式来问我的问题将是:如何使SQL返回只有行从节点表中没有匹配的field_data_field_area_of_study_category表?
foreach($aos_nodes as $aos_node):
if (is_null($aos_node->field_area_of_study_category_tid)):
$menu_item_display[$aos_node->title] = array(
'id' => $aos_node->nid,
'type' => 'node',
'children_markup' => '',
'icon' => '',
'name' => $aos_node->title,
'href' => drupal_get_path_alias('node/'.$aos_node->nid),
);
endif;
endforeach;
有什么问题吗? – 2011-12-28 22:02:02
更具体到@SergeiTulentsev - 如果加入的值为空,你想要做什么? – Eric 2011-12-28 22:03:10
'WHERE field IS NULL'? ['ISNULL(场)'](http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_isnull)? ['IFNULL(field,0)'](http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_ifnull)? – 2011-12-28 22:03:53