Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的产品表结构
product_id product_name --------------------------------- 100 鼠标 101 键盘 101 Pendrive 102 主板 102 读卡器 103 适配器
我想要通过消除重复记录OUTPUT 为我提供以下输出的查询 ------------------ 100 103
我试过这个查询
SELECT count(product_id) FROM product GROUP BY product_id
尝试这个:
SELECT product_id FROM product GROUP BY product_id HAVING COUNT(product_id) = 1;
你可以试试这个 SQL
SELECT t1.product_id FROM (SELECT product_id, COUNT(*) AS cnt FROM table GROUP BY product_id) t1 WHERE t1.cnt = 1