Click here to Skip to main content
16,021,823 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hey folks, I aint sure if this question has been asked before and im sorry if it has but basically, I'm looking to see if anyone here has some code or guidance/idea on how to build a search function where When I type in a "specific" Name or characters, it returns the data but it only returns it if it matches what Ive typed, I aint sure if this can be done and It could mean validation which I aint good with but say for talk sake I had a search box and button and I typed Computer Science, It will only return a module/subject named that, if its spelt wrong or or whatever it wont return.

It will only search the DB table where the names are and display the one that's typed and nothing else.. Can this be done, also if it matches, I have a listview showing data in a specific way, can that be copied or used also so when the search matches it displays the module button like it has on another one of my pages..

If you need any refinement or anything let me know, sorry if it sounds confusing also but any help would be fantastic folks :)

What I have tried:

I have watched youtube videos but nothing matches the specificity of what Im looking to implement :(
Posted
Updated 21-Mar-18 10:25am

1 solution

The simplest way is to use the "LIKE" keyword

SELECT columns FROM MyTable WHERE SomeField LIKE '%hello%'

that will search records where SomeField contains "Hello". To do it better you can also look into enabling and using free text searching on SQL (google for articles on it). The next step would be to use an indexing system like Lucene to index your tables for you and you can execute searches against that too. Google for how to use lucene indexing against sql server.
 
Share this answer
 
Comments
Ryan Doyle 17-Feb-16 12:30pm    
Thanks for the information F-ES, all info welcome, if anyone has any pieces of code that they have implemented in the past thats similar that would be extremely helpful aswell.

Basically I have the idea that I want to only return the result to my specific search and it has to match a valid module. SO for talk sake if I search say a module code like CPT1234, it will return the module name using CPT1234 so for talk sake thats PC Maintenance and I can then click in to view its contents and information, if I search CPT1233 instead of 1234 by accidient I want it to say no specific module id with that id or something like that...

U think this will be okay to implement?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900