function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
munira hazari 3munira hazari 3 

Display result in search box with Exact match of the value and after that the other values that can match.

When a user is passing 2 character in search box, if he types 2 characters in the field , The user display result should be Exact match (Starts with 2 characters) and after that the value of other values that can match(Contains with 2 characters).
 
munira hazari 3munira hazari 3
I have done SOQL query with using Wildcard.But the values comes randomly. It needs to sorted 1st on StartsWith Character basis then on Contains with basis.
Rameshwar gaurRameshwar gaur
public static List<Account> search(String searchKey) {	
		String name = '%'+ searchKey + '%';
		return [SELECT Id,Name FROM Account WHERE Name LIKE : name];

		}

in search box codes use
<ui:inputText aura:id="input"  keyup="{!c.searchKeyChange}" updateOn="keyup" required="true"></ui:inputText>

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ankit