Monday 15 February 2010

mysql - Select case * when -


I'm thinking that something like the title, then says:

  selection Case * WHEN Neil '' ELSE * END I want to do case conditioning for hundreds of columns, so it would be easy if I could get it on the SELECT * statement. Can someone advise me if something like this is in MS SQL Server or MySQL? Thanks   

Try with dynamic SQL ( MySql )

  SELECT GROUP_CONCAT (CONCATES ('COALESCE (`', column_name, '',` ',' ') `', column_name, '`')) @Software, from the information_ SCHEMA.COLUMNS where table_name = 'Table1'; SET @sql = CONCAT ('SELECT', @sql, 'from Table 1'); Prepare SSML with SSMT; EXTUTE STMT; DEALLOCATE STMT;    

No comments:

Post a Comment