JackTheRussel
Programmer
Hi all.
Can you tell me some better way to do this-
I make two queries because I need data from two columns:
name and age.
Persons
ID NAME AGE
1 john 22
2 kim 26
3 paul 32
And I do like this
1.select name from persons
2.push data to @name table
3.select age from persons
4.push data to @age table
5.Then I join these informations under the for-sentences
And I finally get right rows where I have name and age:
john 22
mike 26
paul 32
And then I write data to the file.
So is there any better solution where I dont have to make two diffrent sql-querys? And is there some ready module which writes sql-query results stright to the file etc.. ?
Thank for help.
Can you tell me some better way to do this-
I make two queries because I need data from two columns:
name and age.
Persons
ID NAME AGE
1 john 22
2 kim 26
3 paul 32
And I do like this
1.select name from persons
2.push data to @name table
3.select age from persons
4.push data to @age table
5.Then I join these informations under the for-sentences
Code:
$empty =" ";
for (my $i=0; $i<@age; $i++)
{
@row[$i] =$name[$i].$empty.$age[$i];
}
john 22
mike 26
paul 32
And then I write data to the file.
Code:
$size = @rows;
$file ='/home/xxx/file.txt';
open (H, ">>$file");
for (my $j=0; $j<$size; jt++)
{
print H "$row[$j]\n";
}
close H;
So is there any better solution where I dont have to make two diffrent sql-querys? And is there some ready module which writes sql-query results stright to the file etc.. ?
Thank for help.