使用sqoop的sql简单连接

时间:2017-01-27 03:01:27

标签: hadoop sqoop

我正在尝试使用sqoop运行简单的连接查询。以下是查询。

sqoop import --connect jdbc:mysql://localhost:3306/retail_db --username    root -P --query 'select d.department_name,c.category_name from departments d join categories c on d.department_id = c.category_department_id group by d.department_name,c.category_name where $CONDITIONS' --target-dir /sqoop26 -m 1

但我遇到了以下错误。

ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where  (1 = 0)' at line 1

相同的连接查询在mysql中正常运行。

1 个答案:

答案 0 :(得分:1)

你的sql sintax有错误。像这样使用你之前的whereconditions

select d.department_name,c.category_name from departments d join categories c on d.department_id = c.category_department_id where $CONDITIONS group by d.department_name,c.category_name 

select * from (
select d.department_name,c.category_name from departments d join categories  c on d.department_id = c.category_department_id  
group by d.department_name,c.category_name 
) t where $CONDITIONS