我想将一个表中的信息用作另一查询的输入。
查询(必需的输出):
SELECT * from maintable where year in ('2005','2006','2007','2008');
我在单独的表格中列出了这些年份。附图片。此查询给我错误:
SELECT * from maintable where year in (SELECT * from picture_table) sub_data;
非常感谢您的帮助。预先感谢。
Hive不支持selecting from a subquery。相反,您可以使用semi join。
select * from maintable left semi join picture_table on (maintable.year = picture_table.year)
您忘了为maintable
指定别名:
SELECT * from maintable a where a.year in (SELECT year from picture_table);