MySql statementselect if(count(iColorId)!=0,'Red','Yellow') as strColor from tbl_colorcount the rows in tbl_color table if count has 0 will print red or yellow.