Select all columns except one in MySQL?

后端 未结 30 3222
后悔当初
后悔当初 2020-11-22 00:46

I\'m trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this?

EDIT: There are 53 columns i

30条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 01:12

    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), ',', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '' AND TABLE_SCHEMA = ''), ' FROM 
    '); PREPARE stmt1 FROM @sql; EXECUTE stmt1;

    Replacing

    , and

    提交回复
    热议问题