Re: The like clause of sql



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.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>


.



Relevant Pages

  • Re: Query for Date in SQL vs Access
    ... > Here is my newbie question o' the day. ... > SELECT FieldName ... > FROM TableName ... But when I try this in the Query ...
    (microsoft.public.sqlserver.programming)
  • Re: show null values
    ... That's a little vague. ... Select * from tablename where fieldname is null; ... If you add the table to a query in design view then specifically pull the field ...
    (microsoft.public.access.queries)
  • Re: Delete * from my data
    ... the last, third, argument of REPLACE is two double-quote, nothing in between ... Replace tableName and fieldName as appropriate, ... > I want a query that removes the * from the data. ...
    (microsoft.public.access.queries)
  • Re: Query for Date in SQL vs Access
    ... Note that I changed your date to a non-ambiguous format. ... > SELECT FieldName ... > FROM TableName ... But when I try this in the Query ...
    (microsoft.public.sqlserver.programming)
  • Re: UPDATE TABLE FROM UNBOUND QUERY
    ... This buttons run the TestQuery and I can see the results. ... results of the query, I want to update the main data tale with Moved = Yes, ... Rather than trying to construct the SQL, use the Design view of the query ... AddTables --> TestQuery, Tablename ...
    (microsoft.public.access.modulesdaovba)