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 > about autonumber column in queries ..

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-16-03, 02:57
rusmnicolae rusmnicolae is offline
Registered User
 
Join Date: Nov 2003
Posts: 11
Red face about autonumber column in queries ..

it is possible to generate a sql code to return a automatic incremental row number by an number specified up to number of rows returned (add the initial start number of course)?
Eq.

start to 5000
..5000
..5001
..5002
.. etc
something of

select field1,..fieldn ,<row_number> + start_number from table ;

please tell me if is not possible.... but not wih an auto_increment field from table
i think the triky part is to generate row number.. to add a start number must be easy ( HA - )
Reply With Quote
  #2 (permalink)  
Old 11-16-03, 14:18
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
If you want to generate row numbers, you can use the following in your SELECT query:

SET @rownumber = 0;
SELECT @rownumber := @rownumber + 1 AS RowNumber, ...

This will create row numbers starting at one, so if you want to start at another point, then just set @rownumber equal to one less than the starting point. If you want to return only part of the result set, then just use LIMIT at the end of your SELECT query. Like: "LIMIT 50, 5000" to start at 5000 and return only 50 rows.
Reply With Quote
  #3 (permalink)  
Old 11-17-03, 08:17
rusmnicolae rusmnicolae is offline
Registered User
 
Join Date: Nov 2003
Posts: 11
ole !!!!
THANK-YOU
Reply With Quote
  #4 (permalink)  
Old 11-17-03, 08:48
rusmnicolae rusmnicolae is offline
Registered User
 
Join Date: Nov 2003
Posts: 11
SOMETHING IS WRONG !!!!
THE SQL CODE YOU GIVE ME WORKS ON SERVER AND ON MYSQL CLIENT.
IT JUST DON'T WORK UNDER SOMETHING ELSE
I TRY IT UNDER ACCESS ON PASS THROUGH QUERYES AND IT IS SOMETHING ABOUT SINTAX WITH :=
Reply With Quote
  #5 (permalink)  
Old 11-17-03, 11:25
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Using := is MySQL's way of assigning user variables in the SELECT syntax. Access uses JetSQL syntax. I am not sure exactly what you should do to remedy it. I am not even sure that user variables are allowed in Access (I am not an Access wiz). You might want to present this question in the Access forum.

Quote:
Originally posted by rusmnicolae
SOMETHING IS WRONG !!!!
THE SQL CODE YOU GIVE ME WORKS ON SERVER AND ON MYSQL CLIENT.
IT JUST DON'T WORK UNDER SOMETHING ELSE
I TRY IT UNDER ACCESS ON PASS THROUGH QUERYES AND IT IS SOMETHING ABOUT SINTAX WITH :=
Reply With Quote
  #6 (permalink)  
Old 11-17-03, 12:37
rusmnicolae rusmnicolae is offline
Registered User
 
Join Date: Nov 2003
Posts: 11
OK.THANK-YOU FOR YOUR SUGESTION.IWILL TRY IN THE ACCESS FORUM



THANK-YOU 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