[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How do you query multiple strings in MS Access

Posted on 2011-03-16
4
Medium Priority
?
336 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

656 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