Reputation: 23
I have a database with fields IDPC
, name
, surname
etc. I used autocomplete for search engine in IDPC
input and it works. In input name
or surname
autocomplete works, but it find multiple same names because on the database each name have 2 or 3 pc. So, I wanna find 1 result for name.
Example:
paul 01pc, paul 07pc, paul 11pc.
search engine with autocomplete in input name
results:
paul, paul, paul.
Instead I want only 1 paul
. How can I achieve this?
Upvotes: 0
Views: 1028
Reputation: 89
You can eliminate duplicates by only select the DISTINCT values in your database column.
SELECT DISTINCT name FROM table
From Oracle MySQL Reference Manual:
The ALL and DISTINCT options specify whether duplicate rows should be returned. ALL (the default) specifies that all matching rows should be returned, including duplicates. DISTINCT specifies removal of duplicate rows from the result set. It is an error to specify both options. DISTINCTROW is a synonym for DISTINCT.
From Microsoft SQL Server Documentation:
The DISTINCT keyword eliminates duplicate rows from the results of a SELECT statement. If DISTINCT is not specified, all rows are returned, including duplicates.
Upvotes: 1
Reputation: 93
Select Distinct name from table_name where name<>''
This query will bring the Distinct names to the Page
Upvotes: 1