SELECT c.id, companyname FROM customers c WHERE EXISTS( SELECT orderid FROM orders o WHERE o.customer_id = cu.id)