Solved

How do you query multiple strings in MS Access

Posted on 2011-03-16
4
316 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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

726 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