Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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