首页 > 解决方案 > How to solve mysql nested query?

问题描述

This is my query and output. Now i try to count total sum of unique item_id and name with this

SELECT name, SUM(item_id) 
FROM (SELECT *
      FROM items U
      JOIN users_items UI ON UI.item_id = U.id)

but it shows error

enter image description here

标签: mysqlsql

解决方案


Do you find something below

 select name, sum(item_id) FROM items U
 JOIN users_items UI ON UI.item_id = U.id
 group  by name

推荐阅读