sql join using语法.
什么时候使用
join on条件的两侧字段同名就可以用:
SELECT post.post_id, title, review FROM post INNER JOIN post_comment ON post.post_id = post_comment.post_id ORDER BY post.post_id, post_comment_id
等效于:
SELECT post_id, title, review FROM post INNER JOIN post_comment USING(post_id) ORDER BY post_id, post_comment_id
注意事项: select * 使用Using 会去除重复的关联列
可以看到 常规写法 * 会保留两侧的关联键 post_id
对应到spark-shell中 join(...,Seq(),...) 就是using语法,他会提出结果集中重复的关联字段.
SELECT * FROM post INNER JOIN post_comment ON post.post_id = post_com