3 SQL::Abstract::Manual::Specification
7 These are the examples for the AST
11 The following are example SQL statements and the AST that would represent each
12 one. The SQL used is from the MySQL dialect.
20 ast_version => 0.0001,
30 =item * SELECT NOW() AS time FROM dual AS duality
34 ast_version => 0.0001,
56 args => [ 'duality' ],
61 =item * SELECT 1 FROM foo LEFT OUTER JOIN bar ON ( foo.col1 = bar.col2 )
65 ast_version => 0.0001,
92 args => [ 'foo', 'col1' ],
96 args => [ 'bar', 'col2' ],
103 =item SELECT * FROM foo WHERE name = 'John'
107 ast_version => 0.0001,
110 type => 'Identifier',
115 type => 'Identifier',
123 type => 'Identifier',
135 =item SELECT COUNT(*) FROM foo WHERE name = 'John' AND ( title = 'Mr' OR abbrev = 'Dr' )
139 ast_version => 0.0001,
146 type => 'Identifier',
153 type => 'Identifier',
165 type => 'Identifier',
184 type => 'Identifier',
199 type => 'Identifier',
200 args => [ 'abbrev' ],
215 =item SELECT COUNT(DISTINCT(*)) FROM foo WHERE ( name = 'John' AND title = 'Mr' ) OR abbrev = 'Dr'
219 ast_version => 0.0001,
230 type => 'Identifier',
239 type => 'Identifier',
255 type => 'Identifier',
270 type => 'Identifier',
287 type => 'Identifier',
288 args => [ 'abbrev' ],
301 =item * SELECT foo, bar baz FROM foo ORDER BY bar, baz DESC GROUP BY 1,3,2
305 ast_version => 0.0001,
308 type => 'Identifier',
312 type => 'Identifier',
316 type => 'Identifier',
321 type => 'Identifier',
326 type => 'OrderbyComponent',
328 type => 'Identifier',
334 type => 'OrderbyComponent',
336 type => 'Identifier',
344 type => 'GroupbyComponent',
352 type => 'GroupbyComponent',
360 type => 'GroupbyComponent',
370 =item * SELECT * FROM ( SELECT 1 ) AS foo
374 ast_version => 0.0001,
377 type => 'Identifier',
382 type => 'Identifier',
386 ast_version => 0.0001,
396 type => 'Identifier',
402 =item * INSERT INTO foo ( col1, col2 ) VALUES ( 1, 3 )
406 ast_version => 0.0001,
408 type => 'Identifier',
437 =item * INSERT INTO foo ( col1, col2 ) VALUES ( 1, 3 ), ( 2, 4 )
441 ast_version => 0.0001,
443 type => 'Identifier',
484 =item * UPDATE foo SET col1 = 1
488 ast_version => 0.0001,
490 type => 'Identifier',
510 =item * UPDATE foo SET col1 = 1, col2 = 6
514 ast_version => 0.0001,
516 type => 'Identifier',
545 =item * DELETE FROM foo WHERE col1 = 10
549 ast_version => 0.0001,
551 type => 'Identifier',
559 type => 'Identifier',
571 =item * INSERT INTO foo ( col1, col2 ) SELECT col1, col2 FROM bar;
575 ast_version => 0.0001,
577 type => 'Identifier',
594 ast_version => 0.0001,
597 type => 'Identifier',
601 type => 'Identifier',
606 type => 'Identifier',
619 robkinyon: Rob Kinyon C<< <rkinyon@cpan.org> >>
623 You may distribute this code under the same terms as Perl itself.