Duplicate Record on List Box


I have two logic(one from search box and one from combobox) that populates data on one Listbox.

The problem when i search one record from the search box and then select the same record from the combo box. The record will be displayed twice on the Listbox.

How can i make that the listbox should not have duplicate record?

thanks in advance.
Hi mikmik,

Not 100% sure why you need two different sources to produce the seed data that fills in the Listbox: it would be interesting to know the semantics of the combo box and the listbox to better answer your question. Namely, do you save stuff from the searchbox to the database? Could it be saved to the same entity that feeds the combo-box on later requests?

Let me know and we'll take it from there,

Sounds like you're using two dropdowns in your filter.

Make sure you pass both the values to a single query and use them in an OR / AND statement in the case of an advanced query.
If you're using two separate queries from separate sources you can:
1. Use a union combined with i.e. a NOT EXISTS or just a smart join.
2. Use a temporary table and execute a DISTINCT SELECT on that table.

Usually above solutions aren't very quick and have complex queries so if it's two different tables it would be best to synchronise the data into one 'combined' table and execute normal queries on that.
Besides that filter out any duplicates using unique indexes and a smart syncronisation script.

p.s.: An OML / screenshots would help in getting a clear view on the context.