0

Consider these tables:

  1. Brands (Id, Name, Logo, Ratings)
  2. Products (Id, Title, Picture, Price)

Is it possible to use star selection to select ALL but ID fields from the Brands table in a join?

create view ProductViews
as
select
    p.*,
    -- Is it possible to use star selection to select all fields of the Brands, except the Id field?
    b.Name,
    b.Logo,
    b.Ratings
from Products p
inner join Brands b
on p.BrandId = b.Id
Saeed Neamati
  • 1,427
  • 3
  • 18
  • 32

1 Answers1

1

Is it possible to use star selection to select ALL but ID fields...

No, not without already explicitly listing all the columns you want in a view or CTE first, and then using SELECT * FROM SuchViewOrCTE.

You also shouldn't be using SELECT * most times because it is an anti-pattern that can affect performance and result in broken code as schema changes occur:

  1. Why is SELECT * considered harmful?
  2. "SELECT *" why is it an antipattern
  3. What is the reason not to use select *?
J.D.
  • 37,483
  • 8
  • 54
  • 121