Abhilash Owk
Abhilash Owk

Reputation: 171

Hive join query to list columns from only one table

I am writing a hive query to join two tables; table1 and table2. In the result I just need all columns from table1 and no columns from table2.

I know the solution where I can select all the columns manually by specifying table1.column1, table1.column2.. and so on in the select statement. But I have about 22 columns in table 1. Also, I have to do the same for multiple other tables ans its painful process.

I tried using "SELECT table1.*", but I get a parse exception.

Is there a better way to do it?

Upvotes: 1

Views: 2742

Answers (1)

Saurabh Kumar
Saurabh Kumar

Reputation: 21

Hive 0.13 onwards the following query syntax works:

SELECT a.* FROM a JOIN b ON (a.id = b.id)

This query will select all columns from a. So instead of typing all the column names (making the query cumbersome), it is a better idea to use tablealias.*

Upvotes: 1

Related Questions