View Full Version : contain statement in query
chungtinhlak
02-27-2009, 09:42 AM
I'm trying to run a query to have an extra column to say iif([soi] contains nc, then "JOBs is good", "")
I tried using like but it doesn't work.
thanks
CreganTur
02-27-2009, 09:53 AM
Is nc a string value you're looking for, or is it another field within the table?
chungtinhlak
02-27-2009, 09:55 AM
yes
CreganTur
02-27-2009, 10:26 AM
Is nc a string value you're looking for, or is it another field within the table?
"Yes" does not answer this question. Please specify.
chungtinhlak
02-27-2009, 11:07 AM
nc is a string value in a column within my table.
CreganTur
02-27-2009, 11:47 AM
The first thing that pops out at me is the fact that you do not have nc declared as a string value in your expression. You must wrap strings in quotes (either double or single. It's really a matter of preference; I always use double-quotes out of habit).
The second issue is that Contains is not a valid SQL keyword. However, you could have written that expression as pseudo-code, in which case I'm misreading it.
Does this work?
IIF(soi = "nc", "Job is good", "")
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.