Click to See Complete Forum and Search --> : SQL exclude by a name with a &


lmf232s
07-30-2004, 04:37 PM
I am having issues where the same company is in a table twice but I really on need to read it once. THe company is in the table twice because it has two different locations but i am only worried about one. Because its reading both in, its duping the values and causing my reprots to be off by a few numbers.

Their are no filds to exclude this company from the query except for the company name.

Problem is, the name has a & in the middle so i am getting an error and not sure how to set it up.

Here is the name that I need to stick in a where clause so I do not grab this record.

and companyname <> 'M.L. ME & Associates Inc.'

How should I set this up so that I can exlude this company name from my group of records that I return.

Thanks

buntine
07-30-2004, 08:55 PM
Did you try escaping the ampersand? Or you could use the DISTINCT keyword.

lmf232s
08-01-2004, 11:34 AM
I had a brain fart buntine. Actually What i have works just fine.

and companyname <> 'M.L. ME & Associates Inc.'

The reason I was getting an error was not because of the & sign in the middle of the name. Let me post the whole line of code.

" WHERE Something and something " & _
" and companyname <> 'M.L. ME & Associates Inc.' " _
" ORDER BY 1, 2, 3 ASC "


What was throughing the error was the end of line 2 where I end the string but do not concatanate it with

" _ should be
" & _

So the error was saying something about ( & ) and concatanation.
So I just assumed it was the & in the company name.

buntine
08-02-2004, 03:59 AM
Oh, hehe. It happens to the best of us.