Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:45:21+00:00 2026-06-05T06:45:21+00:00

Have a working SQL statement: my $q_it = $dbh->prepare(SELECT customdata.Field_ID, customdata.Record_ID, customdata.StringValue FROM customdata

  • 0

Have a working SQL statement:

my $q_it = $dbh->prepare("SELECT customdata.Field_ID,
    customdata.Record_ID,
    customdata.StringValue
    FROM customdata
    WHERE customdata.Field_ID='10012' && (StringValue LIKE '1%' OR StringValue LIKE   '2%' OR StringValue LIKE '9%');
   ");

I have written a very simple Perl script for my client to run on their server/db. I could not test it directly, but I passed my code to their DBA:

  $q_it->execute();
   open (MYFILE, '>>data.txt');
    while (my @row=$q_it->fetchrow_array)
    {
       print MYFILE $row[0].$row[1].$row[2];
    }
   close (MYFILE);

$q_it is just a normal SQL Select statement. I would assume the data.txt will contain many records(rows). However, surprisingly, it return the results in a single column, but many rows like:

      100012
      100012
       ...
      100012
      315941
      315667
       ...
      315633 
      2011-06
      2011-06
       ...
      2011-06

There are just about correct no. of rows for “100012”, the “31”values and the date strings. Ideally, it should be

100012  315941 2011-06
100012  315667 2011-06
100012  315633 2011-06

Could it be something I did wrong in my Perl or is this because their MySQL database has different structures?

Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:45:23+00:00Added an answer on June 5, 2026 at 6:45 am

    I would guess that you are looking at a previous attempt to dump the database. To get all values of the first column, followed by all values of the second etc. requires a very different program from the one you have shown.

    Don’t forget that you are opening the file for append, which will leave any old data at the start of the file. I would have thought an open for write would be appropriate here, as the output from failed attempts is of little value.

    I would also check the status of the open using

    open MYFILE, '>', 'data.txt' or die $!;
    

    Apart from that, unless you have set $\ to a newline, you need to terminate your printed output with a newline to separate the records. It is also easier to write

    print "@row\n";
    

    rather than mention each of the fields explicity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following sql statement that is working properly. SELECT * FROM table
I am working on my SQL, and I have the following statement: 1 SELECT
I have a SQL statement, select ColumnName from Table And I get this result,
I have the following SQL statement: USE ws_results_db_2011_09_11_09_06_24;SELECT table_name FROM INFORMATION_SCHEMA.Tables WHERE table_name like
I have the following SQL statement: mysql_query(SELECT * FROM `friends` WHERE friend1='$username' OR friend2='$username'
I have a SQL statement like the following: select A from table1, (select B
I have a sql function that does a simple sql select statement: CREATE OR
I have a sql statement like this (using mysql 5.5.15): select global_id, count(id) as
I have written a working T-SQL MERGE statement. The premise is that Database A
I have the following SQL statement which was working perfectly until I moved it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.