Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a column from SELECT query?

Tags:

sql

I have 100 columns in a table and I want to list 99 columns except a particular one.

How to exclude that columns name?

like image 488
Mithun Sreedharan Avatar asked Sep 06 '10 10:09

Mithun Sreedharan


People also ask

How do I exclude a column from a selection in SQL?

COLUMNS table holds all information about the columns in your MySQL tables. To exclude columns, you use the REPLACE() and GROUP_CONCAT() functions to generate the column names you wish to include in your SELECT statement later.

How do I exclude one column from SELECT in hive?

The easiest way to select specific columns in the Hive query is by specifying the column name in the select statement. SELECT col1, col3, col4 .... FROM Table1; But imagine your table contains many columns (i.e : more than 100 columns) and you need to only exclude a few columns in the select statement.

How do I hide a column in SELECT?

Hide columns Select one or more columns, and then press Ctrl to select additional columns that aren't adjacent. Right-click the selected columns, and then select Hide.

How do I exclude columns from a group by in SQL?

To avoid grouping by a specific column that returns multiple values, you can either remove it from the query, or you can explicitly tell it which value you want. You can do this using aggregate or analytic functions, like: MAX(ExtensionID) MIN(ExtensionID)


1 Answers

The Tutorial D relational database query language does allow a projection to be expressed in terms of the attributes to be removed using ALL BUT however there is no such equivalent syntax in SQL that allows you to do this. You need to explicitly list the specific ones that you want.

You could use a View if you commonly need this same set of columns.

like image 198
Martin Smith Avatar answered Sep 19 '22 20:09

Martin Smith