There are three ways to specify the columns you want in your result set.
select *, which will return all columns available in the query.
select MyTable.* which will return all columns from MyTable. If you have used an alias for the table, you can also use MyAlias.*, which is equivalent.
- Specify all of the columns you want individually, by name.
You can also combine techniques (2) and (3).
It is a good idea to always use technique 3 only.
There is no way to specify columns that you don't want to return, unfortunately.
Examples:
This query will return all columns {T.a, T.b, U.c, U.d}:
create table T (a int, b int);
create table U (c int, d int);
select *
from T
join U on t.a = u.c
This query will return only the columns on T, ie {T.a, T.b}
select T.*
from T
join U on T.a = U.c
This query will return the columns {T.a, T.b, U.d}
select T.a, T.b, U.d
from T
join U on T.a = U.c
This query will return all columns from T, plus column d from U:
select T.*, U.d
from T
join U on t.a = u.c
There is no way to do anything like this:
-- syntax error
select * except U.c
from T
join U on T.a = U.c