sql - 处理 hive 中多个表的连接
问题描述
下面是表a、b、c、d和x的表结构
编写一个查询来查找 id,我希望这可以使用 case 语句来完成,但不知道如何将其放入查询中。
table a
id name address
table b
id name dept
table c
id name dept sal
table d
id name dept address
table x
id name dept address ......
a join x (on id)
if id is null then
a join b (on name and get id) then join x(on id)
if name is null then
a join c (on dept and get name) then join b (on name and get id) then join x(on id)
if dept is null then
a join d(on address get id) then join x on id
解决方案
推荐阅读
- node.js - 运行克隆的 node.js Web 应用程序需要遵循哪些步骤?
- r - 合并长度不等的数据帧而不生成 NA
- dapper - Npgsql 支持异步吗?
- java - Gremlin Spark Java Maven 项目 - 查询响应慢
- c - 使用函数指针和 qsort 进行快速排序
- c# - 将命令行参数传递给 roslyn 编译器
- javascript - 无法读取未定义的属性“变量”-JS
- java - 如果比较器使用了其他一些变量,那么比较器何时消耗该变量?
- parsing - ANTLR 在开始时不识别令牌
- scala - 如何为在 Docker Compose 中运行的 SBT 提供环境变量?