"if... else" statement in MS Access

A

ali

For example,I Have two tables in MS Access
------------------------------------
Table 1:
ID Product Code Price
1 Tea aaa 10
2 Cofee bbb 20
3 Coke ccc 15
4 Bread ddd 30
5 Rice eee 40

--------------------------------------------------
Table 2:
ID FOOD_COD Food_Description Cost
1 aaa Cylon tea, good! 5
2 bbb Cofee, Brazilian cofee 10
3 ccc Coca cola,everyone drinks it 10
4 ddd Farmhouse bread, eat eveyday 10
5 eee Rice, food for all asian peole 15
------------------------------------------------------------------------
My question is :

If "Code from table1" equals to "food_code from table2" , then Price(from
table1) must be devided by Cost (from table2).


so, what SQL should i type in, please simplify the SQL a bit. Thank you ^_^!
 
K

KARL DEWEY

Use a join --
SELECT Table1.Product, Table1.Code, Table1.Price, Table2.Food_Description,
Table2.Cost, [Price]/[Cost] AS Expr1
FROM Table1 INNER JOIN Table2 ON Table1.Code = Table2.FOOD_COD;
 
A

ali

thanks Karl, you rock ! !


--
---------


KARL DEWEY said:
Use a join --
SELECT Table1.Product, Table1.Code, Table1.Price, Table2.Food_Description,
Table2.Cost, [Price]/[Cost] AS Expr1
FROM Table1 INNER JOIN Table2 ON Table1.Code = Table2.FOOD_COD;

--
KARL DEWEY
Build a little - Test a little


ali said:
For example,I Have two tables in MS Access
------------------------------------
Table 1:
ID Product Code Price
1 Tea aaa 10
2 Cofee bbb 20
3 Coke ccc 15
4 Bread ddd 30
5 Rice eee 40

--------------------------------------------------
Table 2:
ID FOOD_COD Food_Description Cost
1 aaa Cylon tea, good! 5
2 bbb Cofee, Brazilian cofee 10
3 ccc Coca cola,everyone drinks it 10
4 ddd Farmhouse bread, eat eveyday 10
5 eee Rice, food for all asian peole 15
------------------------------------------------------------------------
My question is :

If "Code from table1" equals to "food_code from table2" , then Price(from
table1) must be devided by Cost (from table2).


so, what SQL should i type in, please simplify the SQL a bit. Thank you ^_^!
 

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