If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > 2 quick questions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-01-04, 14:33
Strikerz95 Strikerz95 is offline
Registered User
 
Join Date: May 2004
Posts: 28
2 quick questions

The first one is:

When I use a SELECT statement in MySQL to return rows in a table, I get a grandtotal count at the bottom when the console returns the specified rows. I am selecting rows INTO OUTFILE and I do not want the grandtotal part included in the txt file. Is there anyway to get rid of it?

The second one has to do with PERL, so hopefully one of you PERL gurus will know the answer:

I am concatenating text in the code as follows:

Code:
@user_name[$i] = @user_name[$i].1;
I simply want to attach a 1 to the end of the user_name, but when I do it leaves a space between the user_name and the 1, so it looks like this:

bperry 1 instead of bperry1

Is there a way to get rid of that space?

Brian
Reply With Quote
  #2 (permalink)  
Old 07-01-04, 15:04
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Suppressing the "decoration" rows depends on what is producing them. The simple answer in this case is just to have perl ignore them.

The space is because 1 is a number. Now "1" is a string. That should work better!

-PatP
Reply With Quote
  #3 (permalink)  
Old 07-01-04, 16:02
Strikerz95 Strikerz95 is offline
Registered User
 
Join Date: May 2004
Posts: 28
Thanks for the help, I'll get PERL to ignore those lines. However, changing 1 to "1" didn't fix the problem. Any other ideas? Here is a bit more of the code I am using:


Code:
####this assigns a 1 to the end of particular users that meet the requirement with in the loop that this line is contained####
@user_name[$i] = @user_name[$i]."1";

####this line sorts the array####
@user_name2 = sort{$a cmp $b}@user_name;

####this part outputs to HTML####
for ($i=0;$i<$count;$i++)
{
	print "@user_name2[$i]";
	print "<br>";
}
Now the source code for HTML output looks like this where users have a 1 at the end of their user_name:

Code:
<br>SLucero
<br>SManzo
<br>SMartinez
<br>SMartinez
1<br>SMaxwell
<br>SMiers
<br>SMooney
<br>SParzyk
Reply With Quote
  #4 (permalink)  
Old 07-01-04, 16:10
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Just for the jolly factor, between the first a second lines that you posted try using:
Code:
chop(@user_name[$i]);
-PatP
Reply With Quote
  #5 (permalink)  
Old 07-01-04, 16:21
Strikerz95 Strikerz95 is offline
Registered User
 
Join Date: May 2004
Posts: 28
Great! That worked, thanks alot,

Brian
Reply With Quote
  #6 (permalink)  
Old 07-01-04, 19:11
Strikerz95 Strikerz95 is offline
Registered User
 
Join Date: May 2004
Posts: 28
I also have another question. How do you return the first character of an array?
Reply With Quote
  #7 (permalink)  
Old 07-01-04, 22:57
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
There are more ways to get the first character than I can easily count, and each has its own advantages and disadvantages. The "brute force" and "one size fits all" solution is:
Code:
$firstchar = SubString(@array[0], 1, 1);
Depending on just what you envision doing, there are probably both more elegant and more efficient ways of doing that.

-PatP
Reply With Quote
  #8 (permalink)  
Old 07-02-04, 13:22
Strikerz95 Strikerz95 is offline
Registered User
 
Join Date: May 2004
Posts: 28
thanks again
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On