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