Howto check for duplaicte entries in result and remove
Posted: Tue May 25, 2004 10:56 am
Hi,
I'm doing a join select query on two tables. One is a client table and the other a policies table. It is a one to many rlationship, eg. one client can have 1 or more policies, but a policy only belongs to one client.
Now in my resultset, I only want the following to happen. There is only one field from the policies table that I need in the result (eg. broker field), and the rest is all from the client table. If a client has two policies though, it will return 2 entries in the result, where the only field that is different is the broker field.
How do I make it display only one entry, but concatenates the broker fields (eg. broker1, broker2) so I can then display them in one box, and therefore only one row is displayed for this query?
My mySQL query looks like this...
Thanks
Ettiene
I'm doing a join select query on two tables. One is a client table and the other a policies table. It is a one to many rlationship, eg. one client can have 1 or more policies, but a policy only belongs to one client.
Now in my resultset, I only want the following to happen. There is only one field from the policies table that I need in the result (eg. broker field), and the rest is all from the client table. If a client has two policies though, it will return 2 entries in the result, where the only field that is different is the broker field.
How do I make it display only one entry, but concatenates the broker fields (eg. broker1, broker2) so I can then display them in one box, and therefore only one row is displayed for this query?
My mySQL query looks like this...
Code: Select all
SELECT DISTINCT *
FROM client INNER JOIN policies WHERE client.IDNumber = policies.ClientID ORDER BY Surname, InitialsEttiene