?
Solved

How do you query multiple strings in MS Access

Posted on 2011-03-16
4
Medium Priority
?
325 Views
Last Modified: 2012-06-27
Hello,
I am querying multiple tables and I need to query for multiple strings e.g. "*zh" or "blaa*" or "frr*"

this is what I am curently using...

SELECT l_nbr, count(1) AS cnt
FROM (select * from 0219 where l_nbr  like "*zh"
UNION ALL
select * from 0220 where l_nbr  like "*zh"
) AS x
GROUP BY l_nbr;
0
Comment
Question by:groovymonkey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 18

Expert Comment

by:Cluskitt
ID: 35147653
SELECT l_nbr, count(1) AS cnt
FROM (select * from 0219 where l_nbr  like "*zh" or l_nbr like "*zh"
GROUP BY l_nbr
0
 
LVL 18

Expert Comment

by:Cluskitt
ID: 35147684
Nevermind, I misread wrong.

SELECT l_nbr, count(1) AS cnt
FROM 0219 INNER JOIN 0220 ON 0219.Id=0220.Id
WHERE 0219.l_nbr like "*zh" or 0220.l_nbr like "*zh" or 0219.l_nbr like "blaa*"
GROUP BY l_nbr

just keep joining tables and adding conditions.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35147687
try

SELECT l_nbr, count(1) AS cnt
FROM (select * from 0219 where l_nbr  like "*zh" or l_nbr  like "blaa*" or l_nbr  like "frr*"
UNION ALL
select * from 0220 where l_nbr  like "*zh" or l_nbr  like "blaa*" or l_nbr  like "frr*"
) AS x
GROUP BY l_nbr;
0
 
LVL 18

Accepted Solution

by:
Cluskitt earned 2000 total points
ID: 35147779
You can also try:

SELECT l_nbr, count(1) AS cnt
FROM (SELECT * FROM 0219
           UNION ALL
           SELECT * FROM 0220) AS x
WHERE l_nbr like "*zh" or l_nbr  like "blaa*" or l_nbr  like "frr*"
GROUP BY l_nbr
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question