Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With SQL 1

Status
Not open for further replies.

JavaToPerlNowVB

Programmer
Joined
Jul 14, 2005
Messages
84
Location
US
I am trying to rebuild some of the old Queries in old database and I came accross with this
Code:
SELECT gl_maint_action.glfwm_key, [description] & IIf(IsNull([com_a]),""," (" & [com_a] & ")") & IIf(IsNull([com_b]),""," (" & [com_b] & ")") AS [Desc]
FROM gl_maint_action INNER JOIN gl_maint_code ON gl_maint_action.maint_code = gl_maint_code.maint_code;
What I don't understand is this part
Code:
[description] & IIf(IsNull([com_a]),""," (" & [com_a] & ")") & IIf(IsNull([com_b]),""," (" & [com_b] & ")")

I am not sure if anyone can help with this or it has enough information for somebody to understand.

Thanks alot
 
Hi JavaToPerlNowVB

The IIf function returns one of two parts, depending on the evaluation of an expression.

Syntax

IIf(expr, truepart, falsepart)

Your code appears to return a zero length string ("") if com_a is null or com_a in brackets if it is not null. This is the same for com_b and they both get appended to the [description] field. Therefore, if [description] is "Plastic Cup" and [com_a] is "colour red" the return would be "Plastic Cup (Colour Red)" or just "Plastic Cup" if [com_a] has no value.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top