Re: When comparing a field name with a column name of more than one word

From: Alin (alinvaduva@hotmail.com)
Date: 02/17/03


From: "Alin" <alinvaduva@hotmail.com>
Date: Mon, 17 Feb 2003 11:52:51 -0800


Fox,
 You should use the following syntax :

sqltext = sqltext & " FROM ThisDayPoints WHERE
PromoterName = '" &
ThisPromoterName & "' AND DivNumber = " & CStr
(ThisDivision) & " AND MemberID
IN (" & CStr(numFirst) & ", " & CStr(numSecond) & ", " &
CStr(numThird) & ",
" & CStr(numFourth) & ", " & CStr(numFifth) & ", " & CStr
(numSixth) & ", " &
CStr(numSeventh) & ", " & CStr(numEighth) & ");"

Anyway whenever you have to deal with text or date fields
you should use ' in the SELECT syntax.
Good look.
 
>-----Original Message-----
>I am back to normal on the log in issue.
>
>I got so much work done today after days and days of
being stumped.
>Then I ran into this part of the statement which I guess
stopped
>functioning because of syntax. Everything is built around
this and
>now the whole thing is held up again. Any ideas would be
appreciated.
>
>This is my string
>sqltext = sqltext & " FROM ThisDayPoints WHERE
PromoterName = " &
>ThisPromoterName & " AND DivNumber = " & CStr
(ThisDivision) & " AND MemberID
>IN (" & CStr(numFirst) & ", " & CStr(numSecond) & ", " &
CStr(numThird) & ",
>" & CStr(numFourth) & ", " & CStr(numFifth) & ", " & CStr
(numSixth) & ", " &
>CStr(numSeventh) & ", " & CStr(numEighth) & ");"
>
>This is how it prints out
>SELECT * FROM ThisDayPoints WHERE PromoterName = John
Gabriel AND DivNumber
>=
>245 AND MemberID IN (1002, 1003, 1020, 0000, 0000, 0000,
0000, 0000);
>
>The error I am getting is
>Incorrect syntax near 'Gabriel'
>
>Regards,
>Fox
>
>
>"BP Margolin" <bpmargo@attglobal.net> wrote in message
>news:uDgLGv60CHA.1780@TK2MSFTNGP11...
>> Fox,
>>
>> The comparison should work just fine, regardless of the
number of blanks
>in
>> the column.
>>
>> Perhaps there is more than one blank between the first
and last name in
>one
>> of the columns, but not the other?
>>
>> While:
>>
>> 'bob smith' always equals 'bob smith' (one blank in
each string)
>>
>> 'bob smith' never equals 'bob smith' (first string
has two blanks
>between
>> the names, while the second string has only a single
blank
>>
>> Similarly, leading blanks can cause a non-match.
Trailing blanks should
>not
>> affect equality tests.
>>
>> -------------------------------------------
>> BP Margolin
>> Please reply only to the newsgroups.
>> When posting, inclusion of SQL (CREATE TABLE ...,
INSERT ..., etc.) which
>> can be cut and pasted into Query Analyzer is
appreciated.
>>
>>
>> "Fox" <fox @ connexions .net> wrote in message
>> news:urJkVO60CHA.1936@TK2MSFTNGP10...
>> > Do I need a special syntax for a comparison such as
>> >
>> > WHERE PromoterName = ThisPromoterName
>> >
>> > When ThisPromoterName is both a first and last name ?
>> > i.e. ThisPromoterName = bob smith
>> > All exmples in my books have a single word in the
comparison.
>> > I can see that joining them with an undescore would
work,
>> > but isn't there another way ? Actually I could swear
it was
>> > alread working and that maybe I am entirley misguided
>> > by making a different mistake which is now effecting
this part
>> > of the statement.
>> >
>> > Fox
>> >
>> >
>> >
>>
>>
>
>
>.
>



Relevant Pages

  • Re: When comparing a field name with a column name of more than one word
    ... Incorrect syntax near 'Gabriel' ... leading blanks can cause a non-match. ... >> When ThisPromoterName is both a first and last name? ... >> All exmples in my books have a single word in the comparison. ...
    (microsoft.public.sqlserver.security)
  • Re: Syntax for "Not Blank"
    ... for not blanks ... column if there is a date in the date column...what is the syntax for this? ... Excel does not accept the  >0, how should this be written to say "when this ... cell is not blank"? ...
    (microsoft.public.excel.misc)
  • Re: How to avoid Nulls
    ... My results look better after I fixed the syntax. ... Can I lookfor "is not null" and "blanks" in the same query? ...
    (microsoft.public.sqlserver.programming)