What is the best way to get certain columns from a table? By picking the required columns, correct? But what if the table contains 50 columns, 40 of which must be displayed? We may just exclude those 10 columns instead of specifying 40 columns in the SELECT query. Let’s have a look at how it can be done with Apache Hive.
Below examples will let you know how to exclude the columns from the SELECT statement.
SELECT `(sal)?+.+` FROM emp;
The above will hide the “sal” column from emp, leaving only the remaining columns visible. If you want to specify several columns, use the format below.
SELECT `(sal|comm)?+.+` FROM emp;
If you are getting “SemanticException [Error 10004] Invalid table alias or column reference” error then click here for solution.
Hope you find this article helpful.
Please do follow for more interesting updates.