OK, apparently I am going to have to re-write most of the script now because of your suggestion. This is a good thing though because I was able to get the MySQL data into a nicely formatted, comma-delimited csv file.

This is the select statement I used, if anyone is wondering:

SELECT Employee.username, Employee.first_name, Employee.last_name, Dep +artment.name, LocationBuilding.name, PhoneNumbers.phone_id, PhoneNumb +ers.fax_flag, PhoneNumbers.exchange, P.position, OrgChart.supervisor_ +id FROM P INNER JOIN OrgChart ON(P.employee_id=OrgChart.employee_id) +INNER JOIN Employee ON(OrgChart.employee_id=Employee.employee_id) INN +ER JOIN PhoneNumbers ON(Employee.employee_id=PhoneNumbers.employee_id +) INNER JOIN Department ON(OrgChart.department_id=Department.departme +nt_id) INNER JOIN LocationBuilding ON(Department.building_id=Location +Building.building_id) INNER JOIN Location ON(LocationBuilding.buildin +g_id=Location.building_id) INNER JOIN LocationRooms ON(Location.room_ +id=LocationRooms.room_id);" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' +> Employee.csv

Thanks!


In reply to Re^2: Open file, sort data on matching field, close file by rycher
in thread Open file, sort data on matching field, close file by rycher

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.