#!/usr/bin/perl
use warnings;
use strict;
use SQL::Statement;
my $stmt = SQL::Statement->new("
SELECT a, b FROM tblA LEFT JOIN tblB WHERE c > 10 and tblB.d = 5
");
printf "Tables : %s\nSelect Cols : %s\nWhere Cols : %s\n",
join( ', ', @ { $stmt->{org_table_names} } ),
join( ', ', map {$_->display_name} $stmt->columns ),
join( ', ', keys %{ $stmt->{where_cols} } ),
;
# OUTPUT
# Tables : tblA, tblB
# Select Cols : a, b
# Where Cols : tblB.d, c
Note, that as menolly++ mentioned, columns are only associated with tables if explicitly specified in the SQL.
And on a different (off) topic : Congratulations! You are customer number 1,000 at jZedHacksRus. Pick up your door prize on the way out.
|