在yii2中LEFT join AND命令
发布时间:2020-12-13 15:58:27 所属栏目:PHP教程 来源:网络整理
导读:我想在yii2中写一个查询 而且我不知道如何写它 我从文档中尝试了一些东西,但它没有用 这是我的查询 SELECT notification.*,event.title,user.firstname,user.lastname FROM notification LEFT JOIN event ON event.id = notification.source_id AND notifica
我想在yii2中写一个查询
而且我不知道如何写它 我从文档中尝试了一些东西,但它没有用 这是我的查询 SELECT notification.*,event.title,user.firstname,user.lastname FROM notification LEFT JOIN event ON event.id = notification.source_id AND notification.activity_type = "checkin" Where user.firstname in (select id from user where user_id=1) LEFT JOIN user ON user.id = notification.source_id AND notification.activity_type = "friend" Where user.firstname in (select id from user where user_id=1) 这是我现在写的查询,我需要在查询中添加AND函数 $query ->select(['notification.*,user.lastname']) ->from('notification') ->leftJoin('event','event.id = notification.source_id') ->leftJoin('user','user.id = notification.source_id'); 解决方法
您是否尝试过以下方法:
$query ->select(['notification.*,'event.id = notification.source_id AND notification.activity_type = "checkin" ') ->leftJoin('user','user.id = notification.source_id AND notification.activity_type = "friend"'); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |