Solved

How do you query multiple strings in MS Access

Posted on 2011-03-16
4
282 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
  • 3
4 Comments
 
LVL 18

Expert Comment

by:Cluskitt
Comment Utility
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
Comment Utility
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 119

Expert Comment

by:Rey Obrero
Comment Utility
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
Comment Utility
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now