SQL to pass a list of ID's and retrieve data

J

James

I am not a SQL user I have enough knowledge of it to be dangerous. I have a
list of some 400 sample ID's that are used to identify the samples in the
different tables I have.

I want to pull data from 3 different tables, to make it simplier lets call
the tables 1,2,3

Now I want to pull data from only certain field in the table and lets call
the fields
CO2, N1C1, are from table1
Sulfur, NI, are from table2
HE,H2, are from table3

I have a list of 400 sampleIDs (sample1, sample2, sample3, etc...) that I
want to pull this data from, how do I write the SQL for this?

Again thank you for the help
 
J

Jeff Boyce

"How" depends on "what", as in "what data, what structure"? I don't have a
very clear picture of your table structure.

If I interpret your example literally, you have different
elements/molecules/??? in different tables. Why? What does having separate
tables for some of these help you do?

More info, please...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
C

Clif McIrvin

Can you write a query that will give you what you want for a single
sampleID ??? Seems to me that if you can do that, what you need is a way
to step from that to feeding your query an arbitrary list of sampleID's.

Assuming that you can do this, I'd suggest creating a table for your
list of sampleID's:

tblSamples
SampleKey --> PK, Autonumber
sampleID --> [text, from your example], Indexed, Non-Unique

Manually enter a couple (or a few) of your sampleID's into this table.

Modify your query to include this new table with an inner join between
sampleID and your other table(s).

Assuming that your list of 400 sampleID's is in one of the several
formats that you can link or import into Access, then you should be able
to write an append query to add your list of samples to tbsSamples
[delete the test data first!].

Of course, as Jeff said, knowing your table structure would help us
tremendously!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top