如果列中的相同值多一次,则选择一列

时间:2017-08-06 05:29:30

标签: mysql sql

这是我当前的表结构

id       | product             | Price
---------|-------------------------------
01       | Motherboard         | 4000
02       | Processor           | 3000
03       | Motherboard         | 4100
04       | Motherboard         | 4150
05       | RAM                 | 1500
06       | Processor           | 2900

这里我想要SQL查询,我只能选择字段product的值,例如id 01,03,04有相同的产品& id 02,06有相同的产品,所以这里只有一行将从01,03,04&将从02,06和05中选择一行 请帮忙。表名为productHistory

2 个答案:

答案 0 :(得分:1)

QUERY将为$.each($('.recent-work-item'), function(){ var thisid = $(this).attr("data-portfolio-id"); $("[data-portfolio-id="+"'"+thisid+"']").on('mouseenter', function(){ $(this).find('.recent-work-item__overlay').removeClass('show-none'); }); $("[data-portfolio-id="+"'"+thisid+"']").on('mouseleave',function(){ $(this).find('.recent-work-item__overlay').addClass('show-none'); }); });

答案 1 :(得分:-1)

您可以使用DISTINCT或GROUP BY来选择唯一值。

SELECT product
FROM ProductHistory
GROUP BY product;

注意:最好使用 DISTINCT 而不是 GROUP BY 来选择唯一值。

相关问题