SELECT id as value, CASE WHEN customer_type = "company" AND company_name IS NOT NULL THEN CONCAT(company_name, " - ", email) WHEN customer_type = "individual" THEN CONCAT(first_name, " ", last_name, " - ", email) ELSE CONCAT(COALESCE(company_name, CONCAT(first_name, " ", last_name)), " - ", email) END as label FROM customers WHERE status = "active" UNION ALL SELECT id as value, CASE WHEN client_type = "company" AND company_name IS NOT NULL THEN CONCAT(company_name, " - ", email) WHEN client_type = "individual" THEN CONCAT(first_name, " ", last_name, " - ", email) ELSE CONCAT(COALESCE(company_name, CONCAT(first_name, " ", last_name)), " - ", email) END as label FROM clients WHERE status = "active" ORDER BY label