Solved

the format in sql word "like"

Posted on 2000-02-19
2
129 Views
Last Modified: 2012-05-04
I want to make a key word searching.
Firstly,I try to use the sql word "like",but can't get the correct format for the word,because I used a string variable,how can I write the correct format to fulfill this requirement?Or someone else can suggest me a better way to do this?pls be quick,for I am in a hurry to complete the task.Thanks in advance.
0
Comment
Question by:buddha68
2 Comments
 
LVL 3

Expert Comment

by:paulstamp
ID: 2538377
Not entirely sure what you mean -are you talking about in a DB or with variables.

If using variables... use INSTR(SourceString, Match), ie

in instr(Target, "ThisString") <> 0 then msgbox "Found 'ThisString' in " & target

instr returns the position within the first string or the second string or 0 if there is no match, ie will return 2 if you do instr("band, "and")

Hope thats what you mean.
0
 
LVL 6

Accepted Solution

by:
Marine earned 50 total points
ID: 2538384
like condition can be expressed like this.
sSQL = "SELECT * FROM TableName where FieldName Like '%Name%'"
this would work
or if you need it to read it from a text box something like this will do
sSQL = "SELECT * FROM TableName where Name LIKE %'" & Text1.Text & "'%"

OR
LIKE '%" & Text1.Text & "%'
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now