|
-
Aug 4th, 1999, 05:51 PM
#1
Thread Starter
New Member
Hi there
How can I use if in a sql statement for a MS SQL server.
Here is an example in and access database
SELECT iif([t.recMags] = "Blade","$500","%450"), t.recTyreMake, t.recValve
FROM tbltyres t;
The syntax might be wrong but it is the idea that counts ...
Thanks
Clyde
-
Aug 5th, 1999, 06:35 PM
#2
New Member
Clyde,
Why not use SELECT <FIELDS> FROM tbltyres WHERE RECMAGS IN("Blade", "$500", "%450"), or were you specifically wanting to use the iif statement in which case I am unable to help.
Thomas
-
Aug 6th, 1999, 01:04 AM
#3
Frenzied Member
I've never used iif but it appears to return one value if a field test returns true and the other value if false.
The SQL equivalent might be (for the example given -"SELECT iif([t.recMags] = "Blade","$500","%450"), t.recTyreMake,t.recValve
FROM tbltyres t;" :
Select "$500", t.recTyreMake, t.recValve FROM tbltyres t where t.recMags= "Blade"
UNION ALL
Select "%450", t.recTyreMake, t.recValve FROM tbltyres t where t.recMags<> "Blade"
[This message has been edited by JHausmann (edited 08-06-1999).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|