• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

How do I use & symbol as part of text in an Access query?

I'm trying to write a simple query where the & symbol is part of the name (say, D&D Enterprises or D&D Players).  I'm trying to find everything that starts with D&D, but no combination of quotes and wildcard symbols seems to work.  Any ideas?

Thanks...Dave
0
dwarfield2k2
Asked:
dwarfield2k2
  • 5
  • 4
  • 3
  • +1
1 Solution
 
coffeeshopCommented:
Do you want to select data that includes & with a wildcard or do you want to name a field with &?
0
 
ralmadaCommented:
select ... from yourtable
where yourcolumn like '%D&D%'
0
 
coffeeshopCommented:
What database? Works for me (Access) without problem. Have you tried

where yourcolumn like '%D&&D%'
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
dwarfield2k2Author Commented:
I want to include data that includes the &.  The "&" is part of the name.
0
 
coffeeshopCommented:
Try to use the char function

INSERT INTO TEST(TEXT) VALUES('D' || chr(38) || 'D')
0
 
ralmadaCommented:
Another possibility is (again in SQL)
where charindex('&', yourcolumnname) <> 0
or another:

where patindex('%D&D%', yourcolumnname) <> 0  
btw, make sure your database collation is not case sensitive, or check for typos
0
 
dwarfield2k2Author Commented:
Access drives me to distraction, because the wildcard operator that works for it, apparently isn't ANSI standard SQL.  I had to use * instead of %, so the expression that worked was like '*D&D*' I didn't use caps--usually I don't get lazy about case, but at the same time usually it doesn't make a difference with Access--until today!  Thanks.
0
 
ralmadaCommented:
Next time make sure you clarify what database you are using, so we can post the solution that you are looking for. thanks.
0
 
coffeeshopCommented:
Yep - though you want to do this in Oracle or somehting else, because of the wildcards - thats why I ask for the database. But keep in mind that you have to switch back to %, if you have an ODBC-table linked against an access-table, very confusing %-)
0
 
dwarfield2k2Author Commented:
Okay...sorry  about that.  I should have been over in the Access Zone anyway.  I guess something's moving me away from Access and back to Oracle!
0
 
coffeeshopCommented:
can only be gravity :-)
0
 
Anthony PerkinsCommented:
>>Next time make sure you clarify what database you are using<<
It is in the title as in:
How do I use & symbol as part of text in an Access query?
0
 
dwarfield2k2Author Commented:
The only reason I said "partially" was because of the SQL vs Access query wildcard issue.  Your suggestion gave me the spark I needed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now