prevent repeated items in list when using autocomplete

Questionsprevent repeated items in list when using autocomplete
william hindle asked 8 years ago

Using formatoptions in the example from integrations/autocomplete.php

$col["formatoptions"] = array( "sql"=>"SELECT name as k, name as v FROM clients","search_on"=>"name", "update_field" => "name");

I have a similar table but many of the entries are for the same name (and more for quite similar names) so when I want to add a new item and start entering a name I get a long list which includes loads of duplicates. That's visually poor and when there's more than one match it can get difficult to find the right one as it may be way down the list, maybe off-screen

I tried "SELECT name as k, name as v FROM clients GROUP BY name" which seems to do what I want when I try a SQL statement using phpmyadmin but it errors when I use it in the formatoptions context.

1 Answers
Abu Ghufran answered 8 years ago

This is an issue in library and autocomplete query does not currently support group by clause.
For alternate approach, you can use distinct. e.g.

SELECT distinct name as k, name as v FROM clients

Your Answer

13 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?