KZiovas
KZiovas

Reputation: 4799

SQL Exclude a specific column from SQL query result

I have a query where I process columns from two tables and at the end I want ALL colulmns from one temporary table and ONLY ONE column from the other table. Also I do not want the KEY column to appear twice after the join.

I cannot find a clean efficient way to do it. I found these solutions:

  1. Specify all columns explicitly. Bad for obvious reasons if you have to type multiple columns
  2. Get all columns and the DROP the ones you dont need. Not efficient because you carry loads of data and then throwing them away.

Is there a one liner SQL command that leaves out a single column? Is there an SQL command that removes duplicate KEY column after joining?

Thanks!!

Upvotes: 0

Views: 345

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1271241

How about selecting all columns from one table and one from the other?

select t1.*, t2.col
from t1 join
     t2
     on . . . 

Upvotes: 3

Related Questions