Re: The like clause of sql
- From: "Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 7 Apr 2005 12:48:47 -0400
Errors? perhaps you should start at the beginning and describe exactly what
you're trying to do.
Are you using a form to enter a value and you want to build a query string
in code? Or are you trying to let a user enter a value when the query is
run? Or are you trying to write a query that will join two tables in order
to find matches between the two?
Are you trying to find tables with specific names for their fields? You're
not trying to find values in those fields?
--
Ken Snell
<MS ACCESS MVP>
"sefs" <sefsinc@xxxxxxxxx> wrote in message
news:%23wWgUy4OFHA.3380@xxxxxxxxxxxxxxxxxxxxxxx
> Its not that simple because Tablename.FieldName is a fieldname
> so you get errors
>
> btw I am using this sql from ASP accessing MS Access.
>
> I have tried
> "SELECT Count(Email) FROM banemail WHERE (%" & email & "% LIKE '" &
> txtEmail
> & "')"
> but this generates an error to the point that email is undefined which it
> is
> because email will now be translated as a variable and not a field name,
> which makes sense.
>
> So then I have tried
> "SELECT Count(Email) FROM banemail WHERE (%" & "email" & "% LIKE
> 'testvaluegoeshere')"
>
> but then i get Syntax error in query expression '(%email% LIKE
> 'testvaluegoeshere')'
>
> What am i doing wrong there.
>
>
> "Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx> wrote in message
> news:OVfpAn4OFHA.1564@xxxxxxxxxxxxxxxxxxxxxxx
>> Just turn the expression around:
>>
>> SELECT Tablename.*
>> FROM Tablename
>> WHERE "lalafirstitemlala" Like "*" & Tablename.FieldName & "*";
>>
>>
>> --
>>
>> Ken Snell
>> <MS ACCESS MVP>
>>
>>
>> "sefs" <sefsinc@xxxxxxxxx> wrote in message
>> news:%23%23HBHi4OFHA.3512@xxxxxxxxxxxxxxxxxxxxxxx
>> > This dosnt work because....we would have
>> >
>> > SELECT Tablename.*
>> > FROM Tablename
>> > WHERE Tablename.FieldName Like "*" & "lalafirstitemlala" & "*";
>> >
>> > and if Tablename.FieldName = firstitem
>> >
>> > then we would be saying select all records where firstitem LIKE
>> > *lalafirstitemlala*
>> >
>> > as you can see this is really backwards....
>> >
>> > we want records to be selected if (a) the fieldname matches any part of
>> > the
>> > value provided and not (b) the value matches any part of the fieldname.
>> >
>> > Your example is (b) but we want to achieve (a)
>> >
>> > Any more ideas?
>> >
>> >
>> > "Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx> wrote in message
>> > news:uvX$aa4OFHA.2384@xxxxxxxxxxxxxxxxxxxxxxx
>> >> SELECT Tablename.*
>> >> FROM Tablename
>> >> WHERE Tablename.FieldName Like "*" & "YourText" & "*";
>> >>
>> >> --
>> >>
>> >> Ken Snell
>> >> <MS ACCESS MVP>
>> >>
>> >>
>> >> "sefs" <sefsinc@xxxxxxxxx> wrote in message
>> >> news:ujl0%23T4OFHA.1392@xxxxxxxxxxxxxxxxxxxxxxx
>> >> >I have a table that consist of rows of one field.
>> >> >
>> >> > like this
>> >> >
>> >> > 1) firstitem
>> >> > 2) thisitem
>> >> > 3) thatitem
>> >> >
>> >> > I want to compare the values in the table against another value, and
> if
>> >> > the
>> >> > any value in the table is included as part of the other value of
>> >> > that
>> >> > other
>> >> > value i am comparing it against its selected.
>> >> >
>> >> > For example
>> >> >
>> >> > If i compare firstitme against lalalalfirstitemlalala
>> >> > then the first row is added to the selected list and so on.
>> >> >
>> >> > What is the statemnt I should use with the LIKE clause
>> >> >
>> >> > Best regards.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
.
- Follow-Ups:
- Re: The like clause of sql
- From: sefs
- Re: The like clause of sql
- References:
- The like clause of sql
- From: sefs
- Re: The like clause of sql
- From: Ken Snell [MVP]
- Re: The like clause of sql
- From: sefs
- Re: The like clause of sql
- From: Ken Snell [MVP]
- Re: The like clause of sql
- From: sefs
- The like clause of sql
- Prev by Date: select field which contains certain text
- Next by Date: RE: Summing records selected in query
- Previous by thread: Re: The like clause of sql
- Next by thread: Re: The like clause of sql
- Index(es):
Relevant Pages
|