[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


MS Access Query to Get Count of Values based on values from 2nd Table

Posted on 2011-05-11
Medium Priority
Last Modified: 2012-05-11
I have 2 Tables
1st Table has 1 Field in it - KEYWORDS, each value / row is unique
2nd Table has multiple fields, one of which is called KEYWORDS, which can contain multiple KEYWORDs, seperated by a comma.

What I want to do is the following :-
- For every record in Table 1 - I want to show how many times the value appears within Table2

The 2 Tables DO NOT have any common Fields which Link the 2 tables - other than the value in Table1 may appear within a Field (along with others) within Table2

eg. Table1 - Keyword1
      Table1 - Keyword2
      Table1 - Keyword3
      Table1 - Keyword4

      Table2 - Keyword3, Keyword4, Keyword1
      Table2 - Keyword1, Keyword2, Keyword3
      Table2 - Keyword1, Keyword3
      Table2 - Keyword2, Keyword3

Keyword1 = 3
Keyword2 = 2
Keyword3 = 3
Keyword4 = 1
Question by:pjelias
LVL 41

Accepted Solution

Sharath earned 2000 total points
ID: 35744072
try this.
  FROM (Table1 AS t1 
        LEFT JOIN Table2 AS t2 
          ON INSTR(1, t2.KEYWORDS, t1.KEYWORDS, 1) > 0) 

Open in new window

For Keyword3, count is 4.

Author Closing Comment

ID: 35744264

thank you - worked exactly as I needed.

Greatly appreciated - especially the quick response

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

873 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