我有以下问题,我有5张桌子
图书属性(id / id_gender / id_publisher /名称/国家/年份/页面/章节/说明/图片)
作者(id /图片/ author_name /描述)
性别(id /图片)
发布者(id / publishing_company /图片)
Authors_Books(id / id_book / id_author)
我想用(书籍,作者,性别,出版商)填充一个表格
我做了以下查询
$books = DB::table('books')
->join('authors_books', 'books.id', '=', 'authors_books.id_book')
->join('authors', 'authors.id', '=', 'authors_books.id_author')
->join('genders', 'books.id_gender', '=', 'genders.id')
->join('publishers', 'books.id_publisher', '=', 'publishers.id')
->select('books.*', 'authors.author_name', 'genders.gender', 'publishers.publishing_company')
->get();
但是我明白了
{
"id": 1,
"id_gender": 2,
"id_publisher": 2,
"name": "Book Name",
"country": "Country",
"year": 2014,
"pages": 219,
"chapters": 25,
"description": "Test",
"picture": "picture.png",
"created_at": "2019-04-03 10:35:23",
"updated_at": "2019-04-03 10:35:23",
"author_name": "Test Author",
"gender": "Test Gender",
"publishing_company": "Publisher"
},
{
"id": 1,
"id_gender": 2,
"id_publisher": 2,
"name": "Book Name",
"country": "Country",
"year": 2014,
"pages": 219,
"chapters": 25,
"description": "Test",
"picture": "picture.png",
"created_at": "2019-04-03 10:35:23",
"updated_at": "2019-04-03 10:35:23",
"author_name": "Test Author2",
"gender": "Test Gender",
"publishing_company": "Publisher"
},
我得到了两个具有相同内容的集合,但只更改了作者的名字,是否有可能将所有内容放入一个集合中,并在author_name属性中添加一个子集合?