« Return to Thread: Problem on creating root password

re: Counting Row Results inside the select

by Lucas.CTR.Heuman :: Rate this Message:

Reply to Author | View in Thread

I'm sorry, currentreturnrownum() doesn't exist .. I was looking for a
function like that so I can make a result set show what row it is in the
return set.

so I can get select currentrownumber , * from anytable;

then I get
1 (rest of date from the *)
2 (rest of date from the *)
3 (rest of date from the *)
4 (rest of date from the *)
5 (rest of date from the *)
6 (rest of date from the *)
7 (rest of date from the *)
8 (rest of date from the *)

I only need to use it for exporting data to another database.





Wishing you the best you know you deserve,

______________________
Lucas Heuman
CM Web Developer
SRA International, Inc.
FAA, WJHTC/Bldg 300, 2nd Fl., H33
Atlantic City Int'l Airport, NJ  08405
Phone 609.485.5401



"J.R. Bullington" <bullijr@...>
03/28/2007 12:31 PM
Please respond to
bullijr@...


To
<mysql@...>
cc

Subject
re: Counting Row Results inside the select







                                 This may sound mundane, but why not use a
subselect COUNT?

SELECT COUNT(
                                 select concat('Test row
',currentreturnrownum()) as testdata , mytestdata from mytestdatatable;)
FROM mytestdatatable;

(I can't test this as I don't have currentreturnrownum()  and cannot find
this function in v.5).

You may also want to try the SQL_CALC_FOUND_ROWS  and then FOUND_ROWS() to
get the result.

SELECT SQL_CALC_FOUND_ROWS,
                                  concat('Test row
',currentreturnrownum()) as testdata , mytestdata from mytestdatatable;
SELECT FOUND_ROWS();

J.R.

----------------------------------------

                                                                 From:
Lucas.CTR.Heuman@...
Sent: Wednesday, March 28, 2007 10:46 AM
To: mysql@...
Subject: Counting Row Results inside the select

Has anyone found a way to get a result set with the current row return
number in a select statement without using vars?

select concat('Test row ',currentreturnrownum()) as testdata , mytestdata
from mytestdatatable;

+------------------------+-------------------+
|Test row 1             | testdata          |
|Test row 2             | testdata          |
|Test row 3             | testdata          |
|Test row 4             | testdata          |
|Test row 5             | testdata          |
|Test row 6             | testdata          |
|Test row 7             | testdata          |
|Test row 8             | testdata          |
|Test row 9             | testdata          |
+------------------------+-------------------+
(9 rows returned)

Wishing you the best you know you deserve,

______________________
Lucas Heuman
CM Web Developer
SRA International, Inc.
FAA, WJHTC/Bldg 300, 2nd Fl., H33
Atlantic City Int'l Airport, NJ  08405
Phone 609.485.5401



 « Return to Thread: Problem on creating root password