2016-08-05 137 views
0

我有兩個配置單元數據庫,即db1和db2。我有一個名爲table1的db1中的表和db2中的一個名爲table2的表。我想根據table1中的特定列值刪除table2中的一些行。根據另一個數據庫中的表記錄刪除Hive中的記錄

我用下面的查詢,但它無法

DELETE FROM db2.table2 
WHERE db2.table2.F_SESSION IN (
    SELECT F_SESSION FROM db1.table1 
     WHERE db1.table1.STATUS = 1); 

的錯誤是

Error while compiling statement: FAILED: SemanticException [Error 10004]: Line 4:12 Invalid table alias or column reference 'db1': (possible column names are: f_session, status) 

在哪裏我錯了任何線索?順便說一句,我不是一個有經驗的SQL人員。

回答

0

試試這個,

DELETE FROM db2..table2 
WHERE db2..table2.F_SESSION IN (
    SELECT F_SESSION FROM db1..table1 
     WHERE db1..table1.STATUS = 1); 
+0

沒有它沒有。我犯了同樣的錯誤。 – Bala

0

但這個工作

USE db2; 
DELETE FROM table2 WHERE table2.F_SESSION IN ( 
    SELECT F_SESSION FROM db1.table1 AS T1 
     WHERE T1.STATUS = 1); 
相關問題