Generate string in SELECT statment based on booleans in table

  • Thread starter Thread starter Noozer
  • Start date Start date
N

Noozer

The following SQL query demonstrates what I'm trying to do (but it doesn't
work - I get no rows)...

SELECT Code, IF(HardwareFL,"Hardware ", " ") + IF(SoftwareFL,"Software ", "
") + IF(OEMFL, "OEM ", "Retail ") AS Style, Price ORDER BY Code;

....Basically I have a number of boolean columns in my table. I want the
query to generate a single string based on some of those booleans.

I'm trying to do this in an MS Access databse. This query will be the row
source for a listbox on an Access form.
 
There is no FROM clause in the SQL statement, so ACCESS has no idea from
which table it's to draw the records.
 
Oops. My bad.

"FROM Products" should be in there before the ORDER BY clause. Also found
that the function I wanted was "IIF". Still doesn't work though. the Style
column is always empty. This is where I am now.

SELECT Code, IIF(HardwareFL,"Hardware ", " ") + IIF(SoftwareFL,"Software ",
" ") + IIF(OEMFL, "OEM ", "Retail ") AS Style, Price FROM Products ORDER BY
Code;
 
Actually the "+" did work...

I reentered the line into my code and it's working now. All I can figure is
that there was a typo someplace that I was missing.

Thanks all!!
 
Back
Top