在 MySQL 中选择除一列之外的所有列?
我正在尝试使用 select 语句从某个 MySQL 表中获取除一个之外的所有列.有没有简单的方法可以做到这一点?
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?
此表中有 53 列(不是我的设计)
There are 53 columns in this table (NOT MY DESIGN)
推荐答案
其实有一个方法,你当然需要有权限才能这样做...
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;
替换 相关文章、