Using SQL in MS Access 2000

  • Thread starter Thread starter mhraja
  • Start date Start date
M

mhraja

I am trying to run some SQL script in MS Access 2000 for creating
query. But its not take 'IF' and 'ELSE' command. Can someone guide me
that how can I use IF and Else in MS Access 2000.

Kind Regards,
Muhammad Hasnain Raja
 
You can't use If and Else in Access SQL. However, the IIf function is the
equivalent.

IIf(expr, truepart, falsepart)
 
Thanks for replying. But MS Access is not letting me even use the one
you mentioned. The following messages appears.

Invalid SQL Statement; expected 'DELETE', 'INSERT', 'PROCEDURE',
'SELECT', or 'UPDATE'

How can I procede now ?
 
Or may be I am writing this is wrong way, where should I write this If
condition ?

Kind Regards,
Hasnain Raja
 
It's pretty difficult for me to say without seeing what you're trying to
use, and knowing what you're trying to do.
 
I appolgise for making you confused. What I want to do is that lets
suppose we have two columns name A and B. Column A can have either F
or V. Now if I select F I want a list of fruit in Column B and if I
select V in column A then I want list of vegetables in column B.

I hope now my case is clear to you.

Kind Regards,
Hasnain Raja
 
hi Nano,
I appolgise for making you confused. What I want to do is that lets
suppose we have two columns name A and B. Column A can have either F
or V. Now if I select F I want a list of fruit in Column B and if I
select V in column A then I want list of vegetables in column B.
SELECT t.*, Iif(t.A = "F"; "Fruit"; "Vegetable")
FROM
t


mfG
--> stefan <--
 
Thanks Stefan, this seems to be a great help to me. I will try using
this.

Kind Regards,
Hasnain Raja

hi Nano,
I appolgise for making you confused. What I want to do is that lets
suppose we have two columns name A and B. Column A can have either F
or V. Now if I select F I want a list of fruit in Column B and if I
select V in column A then I want list of vegetables in column B.

SELECT t.*, Iif(t.A = "F"; "Fruit"; "Vegetable")
FROM
t

mfG
--> stefan <--
 
hi Hasnain,
Its working and one more thing, Can Vegetable and Fruit be two other
queries too ?
I'm not sure what you mean. Can you explain it?

Maybe

SELECT *
FROM

WHERE A = "F"


mfG
--> stefan <--
 
Back
Top