query value

  • Thread starter Thread starter rml
  • Start date Start date
R

rml

How can I make a query do the following:

If the value in column A = "123" then value of column B = "tree"
If the value in column A = "456" then value of column B = "apple"
If the value in column A = "768" then value of column B = "car"

Thanks.
 
rml said:
How can I make a query do the following:

If the value in column A = "123" then value of column B = "tree"
If the value in column A = "456" then value of column B = "apple"
If the value in column A = "768" then value of column B = "car"

Thanks.

Use a lookup table, ie a table with these (example) fields and values:

tblLookup:
Value (PK) Description
123 tree
456 apple
768 car

.... etc. Include the table in your query and join to the main table using
the "ColumnA" and "Value" fields.

Keith.
www.keithwilby.co.uk
 
Could you provide me with an example?

Thanks!

Keith Wilby said:
Use a lookup table, ie a table with these (example) fields and values:

tblLookup:
Value (PK) Description
123 tree
456 apple
768 car

.... etc. Include the table in your query and join to the main table using
the "ColumnA" and "Value" fields.

Keith.
www.keithwilby.co.uk
 
rml said:
Can anyone help me with an example of this?

I'm not sure what more I can tell you. Assuming your main table has a field
to contain the "number" element (ie "123" etc) then you can link that table
to a lookup table's Primary Key (PK) using that field. Then, when you run a
query based on both tables, whenever you get (for example) "123" in your
main table then lookup will provide "tree" for free.

Keith.
www.keithwilby.co.uk
 
Back
Top