tags:

views:

42

answers:

2

Is it possible to get this if statement to NOT print a column if EQ_Type!='ENGINE'? The empty column on my out put is bothering me.

select if(EQUIPMENT.EQ_Type='ENGINE',ENGINE.Capacity,'') as Capacity, ....

Thanks for your help.

+1  A: 

No - you will have to either have a column for all rows, or omit the comun altogether. You can control exactly what is displayed by using CASE, which is basically the same as you have done using IF (maybe a tad more self-explanatory):

select case when equipment.eq_type = 'ENGINE' then
   engine.capacity
else
   'put something you want here'
end as capacity
from...
davek
See: http://stackoverflow.com/questions/1898472/mysql-if-statement-question
OMG Ponies
+3  A: 

No, you can't selectively include a column on a row by row basis.

OMG Ponies