Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
Question:-Search substring in a string using Ms Access Command line ...
exp:-
i have a line such as "There is a cat behind door"
i want to get "Behind" Word from the given line ...

Ms Access Database:-
Give
Told
Behind
rat

................................................
basically i want to search a substring in a long string ...
textbox contain that string ...
-------------------------------
thnxs in advance
Posted

1 solution

This is complicated, but...
SQL
SELECT * FROM MyTable WHERE INSTR('There is a cat behind door', ' ' + UName + ' ') <> 0
Will do it.
The complications are that it won;t find them at the beginning of the string, or the end, it doesn't work with punctuation, and so forth: those I leave to you!

Personally, I wouldn't try to do it in SQL: I'd use a "proper" language with better string handling and presentation abilities, like C# or even VB.
 
Share this answer
 
Comments
Rohit Malhotra 2-Jul-15 3:13am    
Uname ?
Rohit Malhotra 2-Jul-15 3:18am    
INSTR? Uname?
whats thats Uname for column in db i guess and wat is instr ...?
OriginalGriff 2-Jul-15 3:21am    
UName is a column name - I have no idea what names you gave your table data...
INSTR is an Access Function:
http://www.databasedev.co.uk/access-sql-string-functions.html
Member 10521418 2-Jul-15 3:22am    
thxxxs let me try
Member 10521418 2-Jul-15 3:26am    
the string was in a textbox how to implement that...

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