diff --git a/src/analyze/analyze.cpp b/src/analyze/analyze.cpp
index 0f46eac4ba83885614d5368e7752966d4b131754..1093126682599a1fdc0680a4461e9a033eceffeb 100644
--- a/src/analyze/analyze.cpp
+++ b/src/analyze/analyze.cpp
@@ -173,6 +173,8 @@ void Analyze::get_clause(const std::vector<std::shared_ptr<ast::BinaryExpr>> &sv
         cond.lhs_col = {.tab_name = expr->lhs->tab_name, .col_name = expr->lhs->col_name};
         cond.op = convert_sv_comp_op(expr->op);
         cond.is_subquery = false;
+        cond.is_In = false;
+        cond.is_rhs_val = false;
         if (auto rhs_val = std::dynamic_pointer_cast<ast::Value>(expr->rhs)) {
             cond.is_rhs_val = true;
             cond.rhs_val = convert_sv_value(rhs_val);
@@ -185,15 +187,13 @@ void Analyze::get_clause(const std::vector<std::shared_ptr<ast::BinaryExpr>> &sv
             Context *context = context;
             auto res = sub_query_execute(rhs_select, context);
             // 判断是不是IN
-            cond.is_In = false;
-            cond.is_rhs_val = false;
             if (cond.op == OP_IN) {
                 cond.is_In = true;
             }
             else {
                 cond.is_rhs_val = true;
             }
-            if (res.size() != 1 && !cond.is_In) {
+            if (res.size() > 1 && !cond.is_In) {
                 throw SubQueryError();
             }
             else if (cond.is_In) {
@@ -201,7 +201,9 @@ void Analyze::get_clause(const std::vector<std::shared_ptr<ast::BinaryExpr>> &sv
                 cond.rhs_vals = res;
             }
             else {
-                cond.rhs_val = res[0];
+                if (res.size() > 0) {
+                    cond.rhs_val = res[0];
+                }
             }
         }
         // 判断id in (1, 2)的情况
@@ -235,13 +237,6 @@ void Analyze::check_clause(const std::vector<std::string> &tab_names, std::vecto
             // Skip column existence and type checking for count(*)
             continue;
         }
-        
-        // // Check if the condition is a subquery
-        // if (cond.is_subquery) {
-        //     auto subquery = cond.subquery;
-        //     check_clause(subquery->tables, subquery->conds);
-        //     continue;
-        // }
 
         // Infer table name from column name
         cond.lhs_col = check_column(all_cols, cond.lhs_col);
@@ -281,7 +276,12 @@ void Analyze::check_clause(const std::vector<std::string> &tab_names, std::vecto
                         break;
                 }
             }
-            rhs_type = cond.rhs_vals[0].type;
+            if (cond.rhs_vals.size() > 0) {
+                rhs_type = cond.rhs_vals[0].type;
+            }
+            else {
+                rhs_type = lhs_type;
+            }
         }
         else if (cond.is_rhs_val) {
             auto& rhs_val = cond.rhs_val;