我尝试了以下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,因为这样会给我错误,指出无法识别列。 有帮助吗?
答案 0 :(得分:0)
MySQL中没有FULL JOIN。
您可以使用左连接(或左和右)的并集来模拟它。 您可以在下面根据表格查看示例:
Select * from bu left join bu_brbu on condition
union all
select * from bu right join bu_brbu on condition