Unix Technical Forum

Another Numbering question

This is a discussion on Another Numbering question within the MySQL forums, part of the Database Server Software category; --> A few days ago, Rik gave me the following code that renumber the fieldname column with consecutive numbers. It ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:33 AM
Jeff
 
Posts: n/a
Default Another Numbering question


A few days ago, Rik gave me the following code that renumber the fieldname
column with consecutive numbers.

It worked fine when I ran it directly, but I'm having difficulty in creating
a procedure to do this.

I'm still new to databases in general and mysql more specifically. I've set
up stored procedures before, but I can't seem to get it right when I add in
the set @myvar statement on the first line.

Any suggestions?




SET @myvar := 0;
UPDATE tablname SET fieldname = @myvar:= @myvar + 1 ORDER BY fieldname;
--
Rik Wasmus



--
Posted via a free Usenet account from http://www.teranews.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:02 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com