【发布时间】:2017-06-15 18:46:29
【问题描述】:
我有这个问题
$data=Post::join('category', 'questions.categoryid', '=', 'category.CategoryId')
->where('category.CategoryName','demo')
->join('comments', function ($join) {
$join->on('posts.postId', '=', 'comments.postId')
->where('posts.postId', '!=', 'comments.linkId');
}) ->get();
我有上面的查询,我正在根据类别名称检索所有帖子并使用 cmets 加入表。
一切正常,但以下行不起作用。我的意思是即使添加此行仍然检索所有记录,甚至我尝试将 != 到 <> 但它不起作用
->where('posts.postId', '!=', 'comments.linkId');
【问题讨论】:
-
希望您知道这不是左连接。 Laravel 的连接是内连接。
标签: php mysql laravel laravel-5