this is not a web design question, i'm actually using it in vb.net
but they don't have a database forum in the software development section.
what i am doing:
i have two tables. customer and customer_phones
my visual basic program has a search for customer option,
which returns the customers name & telephone number into a listbox.
select customer.name, if(isnull(customer_phones.number, '', customer_phone_numbers.number) as Phone from customer left join customer_phone_numbers on customer_phones_numbers.Customer_ID = customer.ID WHERE customer.Name LIKE '%whatever%' OR customer_phone_numbers.Number LIKE '%whatever%'
inow, the customer phone numbers table can have as many phone numbers as you want attached to the customer by the customer id.
so my code fills up the list box with the same customer for each phone number he has (hopefully you understand what i mean).
when i only want 1 instance of the customer to appear no matter how many phone numbers he has.
i have tried
group by customer_phones.Number
but if there is a relative ect. that has there own account with same phone number, one of them doesnt appear.
select distinct customer.ID, select distinct customer_phones.Customer_ID
doesn't seem to work either
anyone have any suggestions / input?