Count number of columns in table

select count(column_name) from information_schema.columns where table_name='foo';