Left join, sum and count group by

后端 未结 3 1227
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 04:55

I have 3 tables: goods, store and pics. In the first table goods titles are stored. In the second - balance of goods in different stocks, in the third - links to goods pictures.

3条回答
  •  不要未来只要你来
    2021-02-04 05:56

    First consider the size of the join. If there are two pictures for one good then there will be twice as many rows for this good. Actually the rows will be duplicated but for the picture part. Hence the sum of the store.rest will pick up everything twice. With three pictures you would get three times the output.

提交回复
热议问题