[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    re: Counting Row Results inside the select
From:       Lucas.CTR.Heuman () faa ! gov
Date:       2007-03-28 16:40:57
Message-ID: OF77B3C708.D1ACA04E-ON852572AC.005AC346-852572AC.005B3604 () faa ! gov
[Download RAW message or body]

--=_alternative 005B35F0852572AC_=
Content-Type: text/plain; charset="US-ASCII"

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@innovatim.com> 
03/28/2007 12:31 PM
Please respond to
bullijr@innovatim.com


To
<mysql@lists.mysql.com>
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@faa.gov
Sent: Wednesday, March 28, 2007 10:46 AM
To: mysql@lists.mysql.com
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




--=_alternative 005B35F0852572AC_=--
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic