【发布时间】:2019-02-10 12:06:51
【问题描述】:
我想显示用户一起喜欢的所有相似产品对,所以我想创建一个 VIEW 来动态更新表格。
我收到无法使用子查询创建视图的消息。 我也想过创建一个临时表,但它没有效果。
当存在 VIEW 限制时,如何将查询结果保存在表中?
这是我的查询:
SELECT DISTINCT c.item1
, c.item2
, count(*) as times_liked_together
FROM
( SELECT a.product_id as item1
, b.product_id as item2
FROM items a
join items b
ON a.wishlist_id = b.wishlist_id
AND a.product_id != b.product_id
) c
GROUP
BY c.item1
, c.item2
【问题讨论】:
标签: mysql sql database view phpmyadmin