I have a table in ms-access with column names from A to H
TableA ABCDEFGH
how can I write a query to select all columns except columns B and F. The result of the query should be
ACDEGH
Do we have something like this
select * from TableA except B, F ?
No, you are stuck with
select a, c, d, e, g, h from TableA
No no. You have to use
SELECT A, C, D, E, G, H FROM TableA
And itβs good if you ask me. SELECT * quite vicious.
select A, C, D, E, G, H from TableA
I donβt know for sure, but it is definitely better to explicitly specify the columns you want to select. This makes any potential changes to your table more liveable as you can use aliases, etc.
or, create a view and select from it, as shown below:
CREATE VIEW vTableA as select A, C, D, E, G, H from TableA
You cannot do this. This is '*' or only the fields you specify. This is a big problem? Or is it just that you want something "neat"?
This is a bit of a pain in the ass, and I went to this forum to find another way to do this, but yes, you are stuck in the definition of each column. You can grab all the columns, though by doing something like this:
select ',[' + column_name + ']' from information_schema.columns where table_name = 'your_table_name'
This way you can exclude columns that you don't need pretty quickly. This is especially useful when you have 50+ columns.