-1

I have a table contain 22 columns

I have a query need to SELECT 20 columns

Is any way to do a query like NOT SELECT (the columns i don't want to select)

So I don't need to type SELECT column1, columns2...

Ben
  • 2,562
  • 8
  • 37
  • 62

5 Answers5

2

You cannot do it as you expected. You have to type all the columns you want. If you have run the query many times, you can create a VIEW with selected columns.

DB_learner
  • 1,026
  • 9
  • 15
1

The only way is to specify the columns you want or use the '*' wildcard

SELECT * FROM TABLE

or

SELECT column1, column2...
Sal00m
  • 2,938
  • 3
  • 22
  • 33
1

SQL doesn't allow to hide some columns. You can either select all columns by using SELECT * ... or list columns you need by SELECT col1, col2, ...

Maksym Polshcha
  • 18,030
  • 8
  • 52
  • 77
1

Please check this answer. It is the only way to do that

Select all columns except one in MySQL?

(I can't comment so I put the link as an answer)

Cheers

Community
  • 1
  • 1
jpruizs
  • 485
  • 1
  • 5
  • 19
1

No it is not possible, the expression "select all except" or "NOT SELECT" has not yet been implemented in any existing database.

Roy M J
  • 6,926
  • 7
  • 51
  • 78