我正在尝试在laravel中编写此查询
"SELECT DISTINCT branches.city_id, cities.title FROM branches INNER JOIN cities ON cities.id = branches.city_id WHERE company_id LIKE :id ORDER BY city_id"
我在laravel中为连接写的查询是
App\Branch::select('branches.id','branches.title')->join('regions','regions.id','=','branches.region_id')->where('company_id', $company_id)->get()
它返回的数据只有branch title
和id
。我还想要其他详细信息,例如cities
等。我也从其他发布的问题中得到了一些帮助,但我无法理解加入。