Conditional Query Help

Parsolamew

New member
Local time
Yesterday, 23:53
Joined
Apr 20, 2011
Messages
3
I'm just getting my teeth into Access, which means not only do I not know how to do a lot of things, I don't know enough of the terminology to do proper searches; apologies if this has been asked before.

I've got a table, with analysis types and values in two columns. I want to write a query that looks at values for each type, and if it finds a certain value, returns all values for that analysis type. I can write a query to pull just the records which match the value specified, but I'm basically trying to weed out analysis types that don't have that value at all, rather than just record the matches.

I don't have even the slightest idea where to start. Hopefully this makes enough sense that someone else does.
 
>>I've got a table, with analysis types and values in two columns. I want to write a query that looks at values for each type, and if it finds a certain value, returns all values for that analysis type.<<

Create and save query 1 as qryTypes.
(paste this into SQL view, then after puting in the correct table & column names
switch to design view). Run it. If it works, save as qryTypes
Select [Types], [Values] From [Your Table] WHERE Values = [a certain value]

Then use that query in another query.
Select a.Type, a.Value
from [Analysis Types] as A
inner join qryTypes as qt on a.[Type] = qt.[Type]
order by a.Type, a.Value '(potentially, more than one type will have that value)

This should get you close.
hth,
..bob
 
BTW. Though Bob is no doubt using generic fieldnames, note that both Type and Value are reserved words and should be avoided.
 

Users who are viewing this thread

Back
Top Bottom