Hello!!
I have a question, I am working on a big table that I need to turn into little tables using customernumber a lot of times the customernumber has no movements, the table appears with zero rows, so I want to tell the SELECT I use to not create the table if its zero rows, this is how I have it right now
CREATE TABLE $tableNameexpt SELECT * FROM final_exp WHERE pat = $row[0
+]
the last part is like that because I am programming in perl, when run it creates these table with zero rows, how can I avoid them?
my $sthexpt = $dbhexpt->prepare("SELECT DISTINCT PAT FROM xpatentes");
$sthexpt->execute();
# Just print the values of 'pat' from the patentes table.
while ( (my @row) = $sthexpt->fetchrow_array() ) {
print "El nombre del proximo archivo ... E$row[0]\n";
}
$sthexpt->execute(); # we've looped through all of the query results
+ above so
#--
# Create the new tables.
#
while ( (my @row) = $sthexpt->fetchrow_array() ) {
my $tableNameexpt = "E" . $row[0]; # table names can not begin w
+ith a digit
print "Creando tabla " . $tableNameexpt . "\n";
my $a_sthexpt = $dbhexpt->prepare("CREATE TABLE TableNameexpt SEL
+ECT * FROM final_exp WHERE pat = $row[0]");
$a_sthexpt->execute();
}
I just wants to see create it the one with one or more rows, can someone help me?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.