all groups > sql server mseq > october 2004 >
You're in the

sql server mseq

group:

& in the where clause


& in the where clause JIM.H.
10/22/2004 5:09:06 AM
sql server mseq:
Hello,

SELECT discounts.*, discounttype AS Expr1
FROM discounts
WHERE (discounttype = 'Initial & Customer')

This query in pub database does not bring anything because of ‘&’ in where
clause. How can I get this working without removing & in the table?
Thanks,
Jim.

Re: & in the where clause Vishal Parkar
10/23/2004 12:23:49 AM
not sure, why do you want to do that. but if you are using "=" equal
operator for comparison then query will look for exact match in the table.
If exact match is not found then you will not retrieve any row.

either change source data or change the value that is being passed in where
clause.

you may try something as follows:

SELECT discounts.*, discounttype AS Expr1
FROM discounts
WHERE replace(discounttype, ' ', ' & ') = 'Initial & Customer'

--
Vishal Parkar
vgparkar@yahoo.co.in | vgparkar@hotmail.com

Re: & in the where clause Steve Kass
10/23/2004 12:36:47 AM
pubs.dbo.discounts has a row where discounttype = 'Initial Customer' If
you want the row because it contains Initial and Customer, then you can
try something like

select ...
from discounts
where discounttype like '%Initial%' and discounttype like '%Customer'

I'm not sure what the point of the string 'Initial & Customer' is.

SK

[quoted text, click to view]
AddThis Social Bookmark Button