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,
23 type => 'SelectComponent',
33 =item * SELECT NOW() AS time FROM dual AS duality
37 ast_version => 0.0001,
40 type => 'SelectComponent',
52 type => 'TableIdentifier',
61 =item * SELECT 1 FROM foo LEFT OUTER JOIN bar ON ( foo.col1 = bar.col2 )
65 ast_version => 0.0001,
68 type => 'SelectComponent',
81 type => 'TableIdentifier',
88 type => 'TableIdentifier',
100 type => 'Identifier',
105 type => 'Identifier',
114 =item SELECT * FROM foo WHERE name = 'John'
118 ast_version => 0.0001,
121 type => 'SelectComponent',
123 type => 'Identifier',
129 type => 'TableIdentifier',
131 type => 'Identifier',
140 type => 'Identifier',
152 =item SELECT COUNT(*) FROM foo WHERE name = 'John' AND ( title = 'Mr' OR abbrev = 'Dr' )
156 ast_version => 0.0001,
159 type => 'SelectComponent',
165 type => 'Identifier',
173 type => 'TableIdentifier',
175 type => 'Identifier',
188 type => 'Identifier',
207 type => 'Identifier',
222 type => 'Identifier',
223 element1 => 'abbrev',
238 =item SELECT COUNT(DISTINCT(*)) FROM foo WHERE ( name = 'John' AND title = 'Mr' ) OR abbrev = 'Dr'
242 ast_version => 0.0001,
245 type => 'SelectComponent',
255 type => 'Identifier',
265 type => 'TableIdentifier',
267 type => 'Identifier',
284 type => 'Identifier',
299 type => 'Identifier',
316 type => 'Identifier',
317 element1 => 'abbrev',
330 =item * SELECT foo, bar baz FROM foo ORDER BY bar, baz DESC GROUP BY 1,3,2
334 ast_version => 0.0001,
337 type => 'SelectComponent',
339 type => 'Identifier',
344 type => 'SelectComponent',
346 type => 'Identifier',
351 type => 'SelectComponent',
353 type => 'Identifier',
359 type => 'TableIdentifier',
361 type => 'Identifier',
367 type => 'OrderbyComponent',
369 type => 'Identifier',
375 type => 'OrderbyComponent',
377 type => 'Identifier',
385 type => 'GroupbyComponent',
392 type => 'GroupbyComponent',
399 type => 'GroupbyComponent',
408 =item * UPDATE foo SET col1 = 1
412 ast_version => 0.0001,
414 type => 'TableIdentifier',
416 type => 'Identifier',
422 type => 'SetComponent',
435 =item * INSERT INTO foo ( col1, col2 ) VALUES ( 1, 3 )
439 ast_version => 0.0001,
441 type => 'TableIdentifier',
443 type => 'Identifier',
473 robkinyon: Rob Kinyon C<< <rkinyon@cpan.org> >>
477 You may distribute this code under the same terms as Perl itself.