473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to search a string

134 100+
How do I search a string -
I have a ms access table consist of 2 columns -

"Part Nos"..........."Components"
K123456............. U123,Q545,U5,Q3321,U22
P456789..............U13,U18,Q123,P555,X222

User enter a component number such as U5 and I must be able to retrieve
the Part Nos -K123456. How do I search thru the string in the "Components" column which is separate by comma.
May 22 '08 #1
5 1139
debasisdas
8,127 Expert 4TB
You have to use LIKE search in database.
May 23 '08 #2
CyberSoftHari
487 Expert 256MB
You can not split and search instead you can use Like %string%
(i.e)
Expand|Select|Wrap|Line Numbers
  1. Select * from tblTableName where SearchField like %searchString%
May 23 '08 #3
jamesnkk
134 100+
You can not split and search instead you can use Like %string%
(i.e)
Expand|Select|Wrap|Line Numbers
  1. Select * from tblTableName where SearchField like %searchString%
thanks you so much for the code
May 24 '08 #4
devonknows
137 100+
Just thought i would offer a few modifications here if not for you then for others that would like to know.

Im assuming searchString is a variable (Which it would be if you was entering the search string into a textbox of some sorts), if so then the sql statement is not valid, beacuse it will just search the table for the word 'searchstring'.

This is the Old One.
Expand|Select|Wrap|Line Numbers
  1. • Sql = "Select * from tblTableName where SearchField like %searchString%"
This is What it Should be.
Expand|Select|Wrap|Line Numbers
  1. • Sql = "Select * from tblTableName where SearchField like '%" & SearchString & "%'"
Also, If your SearchString is more than one word like a two word phrase or something and you want to search for all instances of these words instead of the phrase as a whole then try something like this.

Expand|Select|Wrap|Line Numbers
  1. • Sql = "Select * from tblTableName where SearchField like '%" & Replace(SearchString, chr(32), chr(37)) & "%'"
What this does, it is replaces spaces (Chr(32)) with percentages (Chr(37)). if there is a percentage in the phrase it will be queried as a wildcard and will return all instances before the % and after the % or between multiple %.

Hope this is a little more insight
Kind Regards
Devon.
May 29 '08 #5
CyberSoftHari
487 Expert 256MB
Most welcome for your valuable reply.
May 29 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1:...
4
by: Ken Fine | last post by:
I'm looking to find or create an ASP script that will take a string, examine it for a search term, and if it finds the search term in the string, return the highlighted search term along with the...
22
by: Phlip | last post by:
C++ers: Here's an open ended STL question. What's the smarmiest most templated way to use <string>, <algorithms> etc. to turn this: " able search baker search charlie " into this: " able...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
0
by: Hriday | last post by:
Hi there, I am working on a web application in ASP.NET My web server and AD machine are in the same domain but located on diffrent phisical machine, I am not able to search user's info by the...
1
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly...
4
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.