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 element1 => 'duality',
61 =item * SELECT 1 FROM foo LEFT OUTER JOIN bar ON ( foo.col1 = bar.col2 )
65 ast_version => 0.0001,
105 =item SELECT * FROM foo WHERE name = 'John'
109 ast_version => 0.0001,
112 type => 'Identifier',
117 type => 'Identifier',
125 type => 'Identifier',
137 =item SELECT COUNT(*) FROM foo WHERE name = 'John' AND ( title = 'Mr' OR abbrev = 'Dr' )
141 ast_version => 0.0001,
148 type => 'Identifier',
155 type => 'Identifier',
167 type => 'Identifier',
186 type => 'Identifier',
201 type => 'Identifier',
202 element1 => 'abbrev',
217 =item SELECT COUNT(DISTINCT(*)) FROM foo WHERE ( name = 'John' AND title = 'Mr' ) OR abbrev = 'Dr'
221 ast_version => 0.0001,
232 type => 'Identifier',
241 type => 'Identifier',
257 type => 'Identifier',
272 type => 'Identifier',
289 type => 'Identifier',
290 element1 => 'abbrev',
303 =item * SELECT foo, bar baz FROM foo ORDER BY bar, baz DESC GROUP BY 1,3,2
307 ast_version => 0.0001,
310 type => 'Identifier',
314 type => 'Identifier',
318 type => 'Identifier',
323 type => 'Identifier',
328 type => 'OrderbyComponent',
330 type => 'Identifier',
336 type => 'OrderbyComponent',
338 type => 'Identifier',
346 type => 'GroupbyComponent',
354 type => 'GroupbyComponent',
362 type => 'GroupbyComponent',
372 =item * UPDATE foo SET col1 = 1
376 ast_version => 0.0001,
378 type => 'Identifier',
383 type => 'SetComponent',
397 =item * INSERT INTO foo ( col1, col2 ) VALUES ( 1, 3 )
401 ast_version => 0.0001,
403 type => 'Identifier',
430 =item * DELETE FROM foo WHERE col1 = 10
434 ast_version => 0.0001,
436 type => 'Identifier',
444 type => 'Identifier',
456 =item * SELECT * FROM ( SELECT 1 ) AS foo
460 ast_version => 0.0001,
463 type => 'Identifier',
468 type => 'Identifier',
472 ast_version => 0.0001,
482 type => 'Identifier',
492 robkinyon: Rob Kinyon C<< <rkinyon@cpan.org> >>
496 You may distribute this code under the same terms as Perl itself.