MySQL - Joining two tables without duplicates?
It's much simpler than you may think:
select distinct(customer_id) from orders;
Edit: If you actually want to get the full info on the customer,
select * from customers where customer_id in (select distinct(customer_id) from orders);
Use:
SELECT c.*
FROM CUSTOMERS c
WHERE EXISTS (SELECT NULL
FROM ORDERS o
WHERE o.custeromid = c.id)
The IN clause is an alternative, but EXISTS works better for duplicates because it returns true on the first duplicate so it doesn't process the entire table.
select customers.id, customers.name, count(orders.id)
from customers
inner join orders on orders.customer_id = customers.Id
group by customers.id, customers.name
having count(orders.id) > 0