使用 sqoop 从 mysql db 连接多个表?

drnojrws  于 2021-04-03  发布在  Hive
关注(0)|答案(1)|浏览(609)

我试过下面的sqoop命令,它可以连接两个表,但不能连接多个表。

sqoop import 
--connect jdbc:mysql://<ip>:6306/siki_asmet?zeroDateTimeBehavior=convertToNull 
--username micronics -P 
--query "SELECT * from bu FULL JOIN bu_brbu USING(id_bu) FULL JOIN bu_jenis USING(id_jenis_bu) WHERE \$CONDITIONS" 
--split-by bu.id_bu 
--target-dir /user/hadoop/joinbu -m 1;

它说语法上有错误

ERROR manager.SqlManager: Error executing statement: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FULL JOIN bu_jenis USING(id_jenis_bu) WHERE  (1 = 0)' at line 1
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FULL JOIN bu_jenis USING(id_jenis_bu) WHERE  (1 = 0)' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)

我不能使用join on,因为它给我的错误,说列不被识别,任何帮助?

llmtgqce

llmtgqce1#

mysql中没有完全连接。
你可以使用左连接的联合(或左右连接)来模拟它。你可以看到下面一个基于你的表的例子。

Select * from bu left join bu_brbu on condition
union all
select * from bu right join bu_brbu on condition

相关问题