Engine
Engine

Reputation: 5432

SELECT * from multiple databases and excluding one column from the result

As mentioned I have 3 databases (or more), and I'm running the following query:

SELECT * 
FROM [dbo].[FeatureVector] f, [dbo].[Defect] d,[dbo].DefectClass c
WHERE f.DefectID = d.DefectID 
  AND f.DefectMapID = d.DefectMapID 
  AND d.GaugeID = d.GaugeID 
  AND d.DefectStatus = 5 
  AND c.ClassID = d.ClassID 
  AND f.Feature0 IS NOT NULL 

I want to exclude from the result one column say XY from the result, I've tried:

SELECT * EXCEPT "XY"
...

and

SELECT * DROP "XY"
...

Upvotes: 0

Views: 558

Answers (2)

abdulla wasay
abdulla wasay

Reputation: 47

Create a view in which you can explicitly specify column names and then use that view in your SELECT query.

Also this is bad practice to use tables as comma separated in SELECT query , you should be using standard JOIN instead.

Upvotes: 0

Milney
Milney

Reputation: 6427

Specify the columns explicitly instead of using *? This is best practice anyway... you really shouldn't use * anywhere as it makes your code brittle

Upvotes: 3

Related Questions