Hi all, I am struggling to write a program in which i have to read 2 cloumns of a table in MySql and then have to put the values of the 2 columns in 2 respective arrays. The tables looks like:
Column1 Column2 apple banana; cat dog; elephant flag; dog home banane kite and so on....
i want to store apple, cat , elephant,dog, banane in one array say as @array1 and banana, dog, flag, home, kite in another array as @array2. Then I have to compare each element of array2 with array1 element. If they are equal, then have to store in a row. I want my output as
Column1 Column2 Column3 apple banana kite cat dog home elephant flag and so on....
my code looks like..
my $sth = $dbh->prepare("INSERT INTO Test3 values (?,?)"); my $order1 = $dbh->prepare("SELECT Column1 FROM Test3 ORDER BY Column1 +"); $sth->execute($words[0],$words[1]) or die $DBI::errstr; $order1->execute(); while(@row = $sth->fetchrow_array()) { print qw($row[0]\n$row[1]\n$row[2]\n);} $sth->finish(); $order1->finish();
Also, how can I split a table(Table T1) having two columns(Column1 and Column2) into two table(T2 and T3) having one column each. i.e. T2 has Column1 and T3 has Column2. But am unable to get the desired output. Many thanks in advance..

In reply to perl and mysql column by sharan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.