查询:
select distinct (Customer) ,CustomerID from history where Customer != '' and Customer LIKE 'Ram%';
结果:
Ramer ram100
Raman ra45
Raman ra45
答案 0 :(得分:3)
尝试使用MAX
和group by
。
select Customer, MAX(CustomerID) CustomerID
from history
where Customer != '' AND Customer LIKE 'Ram%'
GROUP BY Customer
答案 1 :(得分:0)
如果您还想查看所有客户ID,请使用group_concat
select customer, group_concat(distinct customerid)
from history
where Customer != '' and Customer like 'Ram%'
group by customer