=head1 NAME SQL::Abstract::Manual::Specification =head1 DESCRIPTION These are the examples for the AST =head1 EXAMPLES The following are example SQL statements and the AST that would represent each one. The SQL used is from the MySQL dialect. =over 4 =item * SELECT 1 { type => 'select', ast_version => 0.0001, select => [ { type => 'SelectComponent', value => { type => 'Value', subtype => 'number', value => 1, }, }, ], } =item * SELECT NOW() AS time FROM dual AS duality { type => 'select', ast_version => 0.0001, select => [ { type => 'SelectComponent', value => { type => 'Function', function => 'NOW', }, as => { type => 'Identifier', element1 => 'time', }, }, ], tables => { type => 'TableIdentifier', value => { type => 'Identifier', element1 => 'dual', }, as => 'duality', }, } =item * SELECT 1 FROM foo LEFT OUTER JOIN bar ON ( foo.col1 = bar.col2 ) { type => 'select', ast_version => 0.0001, select => [ { type => 'SelectComponent', value => { type => 'Value', subtype => 'number', value => 1, }, }, ], tables => { type => 'Operator', op => 'LEFT OUTER', args => [ { type => 'TableIdentifier', value => { type => 'Identifier', element1 => 'foo', }, }, { type => 'TableIdentifier', value => { type => 'Identifier', element1 => 'bar', }, }, ], on => { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'foo', element2 => 'col1', }, { type => 'Identifier', element1 => 'bar', element2 => 'col2', }, ], }, }, } =item SELECT * FROM foo WHERE name = 'John' { type => 'select', ast_version => 0.0001, select => [ { type => 'SelectComponent', value => { type => 'Identifier', element1 => '*', }, }, ], tables => { type => 'TableIdentifier', value => { type => 'Identifier', element1 => 'foo', }, }, where => { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'name', }, { type => 'Value', subtype => 'String', element1 => 'John', }, ], }, } =item SELECT COUNT(*) FROM foo WHERE name = 'John' AND ( title = 'Mr' OR abbrev = 'Dr' ) { type => 'select', ast_version => 0.0001, select => [ { type => 'SelectComponent', value => { type => 'Operator', op => 'COUNT', args => [ { type => 'Identifier', element1 => '*', }, ], }, }, ], tables => { type => 'TableIdentifier', value => { type => 'Identifier', element1 => 'foo', }, }, where => { type => 'Operator', op => 'AND', args => [ { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'name', }, { type => 'Value', subtype => 'String', element1 => 'John', }, ], }, { type => 'Operator', op => 'OR', args => [ { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'title', }, { type => 'Value', subtype => 'String', element1 => 'Mr', }, ], }, { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'abbrev', }, { type => 'Value', subtype => 'String', element1 => 'Dr', }, ], }, ], }, ], }, } =item SELECT COUNT(DISTINCT(*)) FROM foo WHERE ( name = 'John' AND title = 'Mr' ) OR abbrev = 'Dr' { type => 'select', ast_version => 0.0001, select => [ { type => 'SelectComponent', value => { type => 'Operator', op => 'COUNT', args => [ { type => 'Operator', op => 'DISTINCT', args => [ { type => 'Identifier', element1 => '*', }, ], }, ], }, }, ], tables => { type => 'TableIdentifier', value => { type => 'Identifier', element1 => 'foo', }, }, where => { type => 'Operator', op => 'OR', args => [ { type => 'Operator', op => 'AND', args => [ { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'name', }, { type => 'Value', subtype => 'String', element1 => 'John', }, ], }, { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'title', }, { type => 'Value', subtype => 'String', element1 => 'Mr', }, ], }, ], }, { type => 'Operator', op => '=', args => [ { type => 'Identifier', element1 => 'abbrev', }, { type => 'Value', subtype => 'String', element1 => 'Dr', }, ], }, ], }, } =item * SELECT foo, bar baz FROM foo ORDER BY bar, baz DESC GROUP BY 1,3,2 { type => 'select', ast_version => 0.0001, select => [ { type => 'SelectComponent', value => { type => 'Identifier', element1 => 'foo', }, }, { type => 'SelectComponent', value => { type => 'Identifier', elements => 'bar', }, }, { type => 'SelectComponent', value => { type => 'Identifier', element1 => 'baz', }, }, ], tables => { type => 'TableIdentifier', value => { type => 'Identifier', element1 => 'foo', }, }, orderby => [ { type => 'OrderbyComponent', value => { type => 'Identifier', element1 => 'bar', }, dir => 'ASC', }, { type => 'OrderbyComponent', value => { type => 'Identifier', element1 => 'baz', }, dir => 'DESC', }, ], groupby => [ { type => 'GroupbyComponent', value => { type => 'Number', value => 1, }, }, { type => 'GroupbyComponent', value => { type => 'Number', value => 3, }, }, { type => 'GroupbyComponent', value => { type => 'Number', value => 2, }, }, ], } =back =head1 AUTHORS robkinyon: Rob Kinyon C<< >> =head1 LICENSE You may distribute this code under the same terms as Perl itself. =cut