Karthik
Karthik

Reputation: 317

Exclude specific columns in select query in MYSQL

I want to select 15 columns from a table of 20 columns. Is there a way to exclude those 5 columns instead of specifying other 15 columns.

Upvotes: 4

Views: 12336

Answers (4)

NinethSense
NinethSense

Reputation: 9028

Include 15 columns than excluding 5. It is a standard practice too.

(Also try to avoid *, it is not standard eventhough it works)

Upvotes: 0

Puppe
Puppe

Reputation: 5125

Create a view containing only the columns you'd like to get.

Upvotes: 2

Egor Pavlikhin
Egor Pavlikhin

Reputation: 17981

I don't think it's possible, and it is not such a good idea. What if your columns change later? Than your results will not correspond to your objects. If your question comes from plain laziness than you probably should reconsider.

Upvotes: 1

cletus
cletus

Reputation: 625007

No, you either have to select them all (*) or list the 15.

Upvotes: 3

Related Questions