I have 2 tables:
我有2张桌子:
Table1: product(id_product, ...)
表1:产品(id_product,...)
Table2: image_product(id_image, id_product).
表2:image_product(id_image,id_product)。
In table 2, we can find that there are many images belong to one single product meaning that we can have many id_image values for the same id_product value.
在表2中,我们可以发现有许多图像属于单个产品,这意味着我们可以为相同的id_product值具有许多id_image值。
What I want to do is to join both tables; However, Table01 contains a lot of data, and to join it with Table02 will cause a lot of redundancy depending on how many images for each product which i think it's not a good practice. So I want to ask if there is a way to join both tables in a way where in one column there is the id_product and in the next column there is a list of all the id_image that belong to that product id.
我想要做的是加入两个表;但是,Table01包含大量数据,并且与Table02连接将导致大量冗余,具体取决于每个产品的图像数量,我认为这不是一个好习惯。所以我想问一下是否有办法以一种方式加入两个表,在一列中有id_product,在下一列中有一个属于该产品id的所有id_image的列表。
3
You have to use group_concat for this problem.
你必须使用group_concat来解决这个问题。
Click Here to understand group_concat with example.
单击此处以通过示例了解group_concat。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2017/02/21/9ba2b27397e3a54326f7d1ac36383952.html。