jeanluca has asked for the wisdom of the Perl Monks concerning the following question:
intoSELECT f1 AS x1,f2,f3,f4 as x2, (f4= f5) as x3 FROM %t"
I need to make 1 big query because I don't want to merge the result of N tables together myself(the WHERE part can get complicated)SELECT x1, f2, f3, x2, x3 FROM ( SELECT f1 AS x1,f2,f3,f4 as x2, (f4= +f5) as x3 FROM Some_table_2006) UNION (SELECT f1 AS x1,f2,f3,f4 as x2 +, (f4= f5) as x3 FROM Some_tabel_2007)) As Tbl1 ;
intoSELECT f1 AS x1,f2,f3,f4 as x2, (f4= f5) as x3 FROM
To simplify the problem I started withSELECT x1,f2,f3,x2, x3 FROM
It turns out that even this exercise is too hard for me. This is what I have so farSELECT f1,f2,f3,f4 as x2, (f4= f5) as x3 FROM
Givesuse strict; use warnings; my $s = "SELECT f1,f2,f3,f4 as x2, (f4= f5) as x3 FROM ...." ; $s =~ s/,\s*.*?\s+as/,/gi ; print "OUT: $s\n";
All suggestions are welcome! or if there are better ways to do this I'm very interested!!OUT: SELECT f1, x2, x3 FROM ....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex needed to remove parts of SQL
by mayaTheCat (Scribe) on Sep 12, 2007 at 10:25 UTC | |
by jeanluca (Deacon) on Sep 12, 2007 at 10:40 UTC | |
by mayaTheCat (Scribe) on Sep 12, 2007 at 11:15 UTC | |
by jeanluca (Deacon) on Sep 12, 2007 at 12:08 UTC | |
|
Re: regex needed to remove parts of SQL
by GrandFather (Saint) on Sep 12, 2007 at 10:50 UTC | |
|
Re: regex needed to remove parts of SQL
by Anonymous Monk on Sep 12, 2007 at 15:10 UTC |