Select all columns except one in MySQL?
Actually there is a way, you need to have permissions of course for doing this ...
SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<columns_to_omit>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<table>' AND TABLE_SCHEMA = '<database>'), ' FROM <table>');PREPARE stmt1 FROM @sql;EXECUTE stmt1;
Replacing <table>, <database> and <columns_to_omit>
TEMPORARY TABLE
DROP TABLE IF EXISTS temp_tb;CREATE TEMPORARY TABLE ENGINE=MEMORY temp_tb SELECT * FROM orig_tb;ALTER TABLE temp_tb DROP col_a, DROP col_f,DROP col_z; #// MySQLSELECT * FROM temp_tb;
DROP syntax may vary for databases @Denis Rozhnev