sql 使用 sqoop 的简单连接

sql simple join using 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 中没问题。

您的 sql 语法有误。像这样在分组前使用你的 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