diff --git a/types.go b/types.go index ad8c7d9..3032715 100644 --- a/types.go +++ b/types.go @@ -485,11 +485,13 @@ func (q *Query) FromSelect(selectStmt *sqlparser.Select) error { switch right := form.RightExpr.(type) { case *sqlparser.AliasedTableExpr: + join.Query = &Query{} if right.As.String() != "" { - join.Query = &Query{From: From{As: right.As.String()}} + join.Query.From.As = right.As.String() } switch rightExpr := right.Expr.(type) { case sqlparser.TableName: + log.Println("rightExpr:", jsonEncode(rightExpr)) join.Query.From.Table = string(rightExpr.Name.String()) case *sqlparser.Subquery: subQuery := &Query{}