Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query filled with info from two tables

Status
Not open for further replies.

TKSlayer

Technical User
Jan 28, 2004
18
0
0
US
Hi all,


Very new to access...so, I went out and bought the Access 2002 Bible. I've created my first database that gathers 15000 records (11 columns of data) and imports it from a webpage and can prepare reports on gathered data. I've got all of my interfaces designed but I've hit a bit of a snag...I can't get a query to work for me.

The query I need will take a table list of items (around 100 items) and compare it to the large table of 15000 records. If any of the 100 items match in two of the columns in the large table..i'd like it to display those matched records (the entire row...all 11 columns) in another table or perhaps in a query. I've looked now for about 4 days in the access bible and have come to the conclusion that the solution might not be in there. Can anyone help me?
 
What do you mean by matching "in two of the columns"? Does that mean that that specific record has the same value in two columns?
 
The following example of an INNER JOIN query between two tables should get you started. Just update the table names and the field names to match those of your situation:

Select A.*
FROM Table1 as A INNER JOIN Table2 on (A.Field1 = B.Field1) and (A.Field2 = B.Field2);

Post back with any questions.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Sorry I left out the alias B for Table2.

Select A.*
FROM Table1 as A INNER JOIN Table2 as B on (A.Field1 = B.Field1) and (A.Field2 = B.Field2);


Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Ok...trying to apply this but alas...my sql sux.

Select table1.criteria, table2.criteria, table2.criteria2 from table2, table1 where (table1.criteria = table2.criteria) AND (table1.citeria = table2.criteria2)


I'm doing this from memory as I do not have access at home (only at work) so I'll have to test it out tomorrow. However, does it look like it is correct?
 
That won't work as you stated it. There must be a join between the two tables so that only those that match are selected.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top