Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k views
in Technique[技术] by (71.8m points)

表有100个字段,我知道不想要的5个字段名称,怎样不一一列出95个字段名称就select出来?

一张表有100个字段,我知道有5个字段名称{A,B,C,D,E}是不需要的,我怎样写SQL语句把需要的字段从表里select出来,而不需要写出95个字段的名称?
select ????????
from table


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

这个问题不知道能不能解决你的问题?sql-exclude-a-column-using-select-except-columna-from-tablea

思路是:
创建一个临时表,然后把特定的列丢弃掉,然后再查询这张临时表。

/* Get the data into a temp table */
SELECT * INTO #TempTable
FROM YourTable
/* Drop the columns that are not needed */
ALTER TABLE #TempTable
DROP COLUMN ColumnToDrop
/* Get results and drop temp table */
SELECT * FROM #TempTable
DROP TABLE #TempTable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...