@@ -1612,6 +1612,9 @@ toSQL (Q q) = q.sql
16121612from :: forall name cols tables. IsSymbol name => Row.Cons name cols () tables => Proxy (Table name cols) -> Q tables () () ()
16131613from _ = Q { sql: reflectSymbol (Proxy :: Proxy name), values: [] }
16141614
1615+fromAs :: forall @alias name cols tables. IsSymbol name => IsSymbol alias => Row.Cons alias cols () tables => Proxy (Table name cols) -> Q tables () () ()
1616+fromAs _ = Q { sql: reflectSymbol (Proxy :: Proxy name) <> " " <> reflectSymbol (Proxy :: Proxy alias), values: [] }
1617+
16151618selectAll
16161619 :: forall tables name cols result r p stage stage'
16171620 . SingleTable tables name cols
@@ -1993,6 +1996,61 @@ leftJoin _ (Q q) = Q
19931996 , values: q.values
19941997 }
19951998
1999+innerJoinAs
2000+ :: forall @alias @cond name cols tables tables' r p stage
2001+ . IsSymbol name
2002+ => IsSymbol alias
2003+ => IsSymbol cond
2004+ => Row.Lacks alias tables
2005+ => Row.Cons alias cols tables tables'
2006+ => ValidateJoinCondition cond tables'
2007+ => Row.Lacks "select" stage
2008+ => Row.Lacks "insert" stage
2009+ => Row.Lacks "set" stage
2010+ => Row.Lacks "delete" stage
2011+ => Proxy (Table name cols)
2012+ -> Q tables r p stage
2013+ -> Q tables' () () (join :: Unit)
2014+innerJoinAs _ (Q q) = Q
2015+ { sql: q.sql
2016+ <> " INNER JOIN "
2017+ <> reflectSymbol (Proxy :: Proxy name)
2018+ <> " "
2019+ <> reflectSymbol (Proxy :: Proxy alias)
2020+ <> " ON "
2021+ <> reflectSymbol (Proxy :: Proxy cond)
2022+ , values: q.values
2023+ }
2024+
2025+leftJoinAs
2026+ :: forall @alias @cond name cols colsRL nullableColsRL nullableCols tables tables' r p stage
2027+ . IsSymbol name
2028+ => IsSymbol alias
2029+ => IsSymbol cond
2030+ => RowToList cols colsRL
2031+ => MakeNullableRL colsRL nullableColsRL
2032+ => ListToRow nullableColsRL nullableCols
2033+ => Row.Lacks alias tables
2034+ => Row.Cons alias nullableCols tables tables'
2035+ => ValidateJoinCondition cond tables'
2036+ => Row.Lacks "select" stage
2037+ => Row.Lacks "insert" stage
2038+ => Row.Lacks "set" stage
2039+ => Row.Lacks "delete" stage
2040+ => Proxy (Table name cols)
2041+ -> Q tables r p stage
2042+ -> Q tables' () () (join :: Unit)
2043+leftJoinAs _ (Q q) = Q
2044+ { sql: q.sql
2045+ <> " LEFT JOIN "
2046+ <> reflectSymbol (Proxy :: Proxy name)
2047+ <> " "
2048+ <> reflectSymbol (Proxy :: Proxy alias)
2049+ <> " ON "
2050+ <> reflectSymbol (Proxy :: Proxy cond)
2051+ , values: q.values
2052+ }
2053+
19962054-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
19972055-- Query execution
19982056-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━