join 2 tables, but filter records

Hutchy

Registered User.
Local time
Today, 06:40
Joined
Jun 28, 2013
Messages
42
I want a query that gives me something like this from 2 different tables:

table1 - AA, AC, DE
table2 - AA01, AA02, AA03, AC01, DE01, DE02

query -
column 1 - column 2
AA - AA01
------ AA02
------ AA03
AC - AC01
DE - DE01
------ DE02

Is that possible?
 
Create a SELECT query that joins both tables via the field you mentioned, go to SQL view and change the join to look like this:

Code:
FROM table1 INNER JOIN table2 ON table2.Field LIKE table1.Field & "*"
 
Create a SELECT query that joins both tables via the field you mentioned, go to SQL view and change the join to look like this:

Code:
FROM table1 INNER JOIN table2 ON table2.Field LIKE table1.Field & "*"

Great!!!
Thanks!

One more thing - how do I get the records in table 1 to not repeat for each record in table 2? If it's possible.
 
You mean like you have it in your first post? It's much easier to do it in a report where you set the Hide Duplicates property of the textbox to Yes.

In a query, you'll need to get the Min() value of Column2 per Column1, e.g.:
Code:
AA - AA[COLOR=Blue]01[/COLOR]
AC - AC[COLOR=Blue]01[/COLOR]
DE - DE[COLOR=Blue]01[/COLOR]
... those are the min values of column2 per column1. Then use an IIF() statement to say:
Code:
New_Column1: IIf(Is Null [COLOR=Blue]MinOfColumn2[/COLOR], Null, Column1)
 

Users who are viewing this thread

Back
Top Bottom