4

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.

0

4 Answers 4

3

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

1

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.

2 Comments

This is possible: check this answer out. Though it still may not be a good idea if your columns changing creates a possibility of something breaking.
If the columns change later he will always have to change the query either way. Actually, for the query itself, it's 3 times as likely he won't have to change it; just have to take care of the treatment of the data afterwards, if it's not a dynamic thing.
0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.