Select all columns except one in MySQL?

后端 未结 30 2894
后悔当初
后悔当初 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:16

    In mysql definitions (manual) there is no such thing. But if you have a really big number of columns col1, ..., col100, the following can be useful:

    DROP TABLE IF EXISTS temp_tb;
    CREATE TEMPORARY TABLE ENGINE=MEMORY temp_tb SELECT * FROM orig_tb;
    ALTER TABLE temp_tb DROP col_x;
       #// ALTER TABLE temp_tb DROP col_a, ... , DROP col_z; #// for a few columns to drop
    SELECT * FROM temp_tb;
    

提交回复
热议问题