diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs
index 09dd213..b737c0f 100644
--- a/Language/SQL/SimpleSQL/Parser.lhs
+++ b/Language/SQL/SimpleSQL/Parser.lhs
@@ -602,7 +602,8 @@ and union, etc..
 > queryExpr :: P QueryExpr
 > queryExpr =
 >   choice [with
->          ,choice [values,select] >>= optionSuffix queryExprSuffix]
+>          ,choice [values,table, select]
+>           >>= optionSuffix queryExprSuffix]
 >   where
 >     select = try (keyword_ "select") >>
 >         Select
@@ -617,6 +618,7 @@ and union, etc..
 >         <*> optionMaybe offset
 >     values = try (keyword_ "values")
 >              >> Values <$> commaSep (parens (commaSep scalarExpr))
+>     table = try (keyword_ "table") >> Table <$> name
 
 > queryExprSuffix :: QueryExpr -> P QueryExpr
 > queryExprSuffix qe =
diff --git a/Language/SQL/SimpleSQL/Pretty.lhs b/Language/SQL/SimpleSQL/Pretty.lhs
index 54a7e2e..5bf3dab 100644
--- a/Language/SQL/SimpleSQL/Pretty.lhs
+++ b/Language/SQL/SimpleSQL/Pretty.lhs
@@ -180,6 +180,8 @@
 > queryExpr (Values vs) =
 >     text "values"
 >     <+> nest 7 (commaSep (map (parens . commaSep . map scalarExpr) vs))
+> queryExpr (Table t) = text "table" <+> name t
+
 
 > alias :: Alias -> Doc
 > alias (Alias nm cols) =
diff --git a/Language/SQL/SimpleSQL/Syntax.lhs b/Language/SQL/SimpleSQL/Syntax.lhs
index 3d9c413..41f9db5 100644
--- a/Language/SQL/SimpleSQL/Syntax.lhs
+++ b/Language/SQL/SimpleSQL/Syntax.lhs
@@ -164,25 +164,13 @@
 >       ,qeViews :: [(Alias,QueryExpr)]
 >       ,qeQueryExpression :: QueryExpr}
 >     | Values [[ScalarExpr]]
-
+>     | Table Name
 >       deriving (Eq,Show,Read)
 
 TODO: add queryexpr parens to deal with e.g.
 (select 1 union select 2) union select 3
 I'm not sure if this is valid syntax or not.
 
-> -- | represents the Distinct or All keywords, which can be used
-> -- before a select list, in an aggregate/window function
-> -- application, or in a query expression set operator
-> data Duplicates = Distinct | All deriving (Eq,Show,Read)
-
-> -- | The direction for a column in order by.
-> data Direction = Asc | Desc deriving (Eq,Show,Read)
-> -- | Query expression set operators
-> data CombineOp = Union | Except | Intersect deriving (Eq,Show,Read)
-> -- | Corresponding, an option for the set operators
-> data Corresponding = Corresponding | Respectively deriving (Eq,Show,Read)
-
 > -- | helper/'default' value for query exprs to make creating query
 > -- expr values a little easier
 > makeSelect :: QueryExpr
@@ -196,6 +184,19 @@ I'm not sure if this is valid syntax or not.
 >                     ,qeLimit = Nothing
 >                     ,qeOffset = Nothing}
 
+
+> -- | represents the Distinct or All keywords, which can be used
+> -- before a select list, in an aggregate/window function
+> -- application, or in a query expression set operator
+> data Duplicates = Distinct | All deriving (Eq,Show,Read)
+
+> -- | The direction for a column in order by.
+> data Direction = Asc | Desc deriving (Eq,Show,Read)
+> -- | Query expression set operators
+> data CombineOp = Union | Except | Intersect deriving (Eq,Show,Read)
+> -- | Corresponding, an option for the set operators
+> data Corresponding = Corresponding | Respectively deriving (Eq,Show,Read)
+
 > -- | Represents a entry in the csv of tables in the from clause.
 > data TableRef = -- | from t
 >                 TRSimple Name
@@ -213,6 +214,9 @@ I'm not sure if this is valid syntax or not.
 >               | TRLateral TableRef
 >                 deriving (Eq,Show,Read)
 
+> -- | Represents an alias for a table valued expression, used in with
+> -- queries and in from alias, e.g. select a from t u, select a from t u(b),
+> -- with a(c) as select 1, select * from a;
 > data Alias = Alias Name (Maybe [Name])
 >              deriving (Eq,Show,Read)
 
diff --git a/TODO b/TODO
index 9cc6256..b30873c 100644
--- a/TODO
+++ b/TODO
@@ -1,39 +1,8 @@
 
 next release:
-lateral since it is easy. I think it is effectively just a prefix
-   operator on tablerefs (can appear like this from lateral a, from
-   lateral a,b, from a, lateral b, from a natural join lateral b
-   (although all of these are sematically garbage, this is the
-   valid syntax)
-more dots: implement as dot operator
 
-row ctor: row(a,b) is fine, but also when there is 2 or more elements,
-   the word row can be omitted: (a,b)
-more symbolic operators, array access a[5]? don't think this is
-   standard sql, if not, leave for now. There is something about
-   arrays in sql:2008
+escapes in string literals
 
-window frames and named windows
-
-
-review tests to copy from hssqlppp
-
-order by nulls first/last
-extend case
-group by extensions. Question: some of the syntax can be represented
-   by app and row ctor, should this be reused or new syntax created
-   (the standard has special syntax for cube and rollup).
-table, values
-collate? -> postfix operator which binds very tightly:
-a < 'foo' collate 'C'
-->
-Op "<" [Iden "a", SpecialOp "collate" [StringLit 'foo', StringLit
-   'C']]
-  also postfix in order by:
-select a from t order by a collate 'C': add to order by syntax, one
-   collation per column
-function table reference
-much more table reference tests, for joins and aliases etc.
 ansi standard versions of limit and offset
 
 OFFSET start { ROW | ROWS }
@@ -45,14 +14,44 @@ in the postgresql docs, the start and count must be in parens unless
 
 + sql server top syntax
 
-quoted identifiers and proper character sets for identifiers
+more dots: implement as dot operator
+
+more symbolic operators, array access a[5]? don't think this is
+   standard sql, if not, leave for now. There is something about
+   arrays in sql:2008
+
+
+
+fix lateral binding issue
+
+row ctor: row(a,b) is fine, but also when there is 2 or more elements,
+   the word row can be omitted: (a,b)
+
+window frames and named windows
+
+review tests to copy from hssqlppp
+
+order by nulls first/last
+extend case
+group by extensions. Question: some of the syntax can be represented
+   by app and row ctor, should this be reused or new syntax created
+   (the standard has special syntax for cube and rollup).
+
+collate? -> postfix operator which binds very tightly:
+a < 'foo' collate 'C'
+->
+Op "<" [Iden "a", SpecialOp "collate" [StringLit 'foo', StringLit
+   'C']]
+  also postfix in order by:
+select a from t order by a collate 'C': add to order by syntax, one
+   collation per column
+much more table reference tests, for joins and aliases etc.
+
+proper character sets for identifiers
 
-run through postgres docs and add example sql as tests
 review internal sql collection for more syntax/tests
 all ansi sql operators
 
-escapes in string literals
-
 review syntax to replace maybe and bool with better ctors
 
 ----
diff --git a/tools/Language/SQL/SimpleSQL/Postgres.lhs b/tools/Language/SQL/SimpleSQL/Postgres.lhs
index 21a9761..78c9a94 100644
--- a/tools/Language/SQL/SimpleSQL/Postgres.lhs
+++ b/tools/Language/SQL/SimpleSQL/Postgres.lhs
@@ -263,17 +263,3 @@ select page reference
 >     ,"SELECT distributors.* WHERE distributors.name = 'Westward';"
 
 >     ]
-
-
-> {-f = mapM_ (putStrLn . either peFormattedError show . parseQueryExpr "" Nothing)
->       ["SELECT * FROM t1 CROSS JOIN t2;"
->       ,"SELECT * FROM t1 INNER JOIN t2 ON t1.num = t2.num;"
->       ,"SELECT * FROM t1 INNER JOIN t2 USING (num);"
->       ,"SELECT * FROM t1 NATURAL INNER JOIN t2;"
->       ,"SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num;"
->       ,"SELECT * FROM t1 LEFT JOIN t2 USING (num);"
->       ,"SELECT * FROM t1 RIGHT JOIN t2 ON t1.num = t2.num;"
->       ,"SELECT * FROM t1 FULL JOIN t2 ON t1.num = t2.num;"
->       ,"SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num AND t2.value = 'xxx';"
->   -    ,"SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num WHERE t2.value = 'xxx';"]-}
-
diff --git a/tools/Language/SQL/SimpleSQL/QueryExprComponents.lhs b/tools/Language/SQL/SimpleSQL/QueryExprComponents.lhs
index e43a554..452da03 100644
--- a/tools/Language/SQL/SimpleSQL/QueryExprComponents.lhs
+++ b/tools/Language/SQL/SimpleSQL/QueryExprComponents.lhs
@@ -24,6 +24,7 @@ These are a few misc tests which don't fit anywhere else.
 >     ,combos
 >     ,withQueries
 >     ,values
+>     ,tables
 >     ]
 
 
@@ -199,3 +200,8 @@ These are a few misc tests which don't fit anywhere else.
 >       ,Values [[NumLit "1", NumLit "2"]
 >               ,[NumLit "3", NumLit "4"]])
 >     ]
+
+> tables :: TestItem
+> tables = Group "tables" $ map (uncurry TestQueryExpr)
+>     [("table tbl", Table "tbl")
+>     ]