2017-01-27 81 views
0

我想使用sqoop運行一個簡單的連接查詢。以下是查詢。sql簡單連接使用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中正常運行。

回答

0

你在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 
+0

哦!男人我沒有想過$ CONDITIONS是where子句的一部分,並作爲最後一個選項放置....謝謝! –