mysql 查询除了某些字段外的所有字段
可以使用 SELECT * 语句来查询所有字段,再使用 SELECT * 除去不需要的字段。例如,如果要查询一个名为 table1 的表,除了字段 col1 和 col2 之外的所有字段:
SELECT *,
(SELECT column_name
FROM information_schema.columns
WHERE table_name = 'table1' AND column_name = 'col1') as null,
(SELECT column_name
FROM information_schema.columns
WHERE table_name = 'table1' AND column_name = 'col2') as null
FROM table1;
这样就可以查询除了 col1 和 col2 之外的所有字段。
原文地址: https://www.cveoy.top/t/topic/dqGy 著作权归作者所有。请勿转载和采集!