Re: Can a row be refered using row number?
The reason for this is probably because the original poster inherited a database without a primary key, and now needs to make edits to it. That happened to me with Oracle once, and I was lucky enough to be able to use Oracle's rowid, which is a unique reference to the row that is independent of the primary key. Unfortunately, MySQL has no such allowance. As others have stated, the best way to accomplish this is to add a primary key to the table, and hope you don't break any code downstream. It may be worth a look at the table description to make sure one doesn't already exist. On 8/10/06, Bartis, Robert M (Bob) <[EMAIL PROTECTED]> wrote: Why would you want to do this? As data moves around within the table the updates will be in error. Wouldn't it be easier to assign a unique key to each row, search for the key or unique set of information and update the resulting row? Bob -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Can a row be refered using row number?
At 14:13 +0530 8/10/06, <[EMAIL PROTECTED]> wrote: Hi All, Is there any way to refer a row based on the row number or row count? I just the effect as below... E.g. UPDATE TBL_NAME SET COL_NAME = xyz WHERE ROW_NO=4 Or SELECT COL_NAME FROM TBL_NAME WHERE ROW_NO=5 No, because you don't know what the row number is. Even if you did, the number is not guaranteed to remain the same over time. The table should include a primary key, so that you can refer to each row in the table by its unique key number. -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Can a row be refered using row number?
Bartis, Robert M (Bob) wrote: > Why would you want to do this? As data moves around within the table the > updates will be in error. Wouldn't it be easier to assign a unique key to > each row, search for the key or unique set of information and update the > resulting row? > > Bob I don't know, maybe that's what Ravi was referring to. In which case, I'd direct ravi to the auto_increment attribute for an INT and the primary key. -- John Meyer http://pueblonative.wordpress.com http://pueblonative.110mb.com/board -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Can a row be refered using row number?
Why would you want to do this? As data moves around within the table the updates will be in error. Wouldn't it be easier to assign a unique key to each row, search for the key or unique set of information and update the resulting row? Bob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, August 10, 2006 4:43 AM To: mysql@lists.mysql.com Subject: Can a row be refered using row number? Hi All, Is there any way to refer a row based on the row number or row count? I just the effect as below... E.g. UPDATE TBL_NAME SET COL_NAME = xyz WHERE ROW_NO=4 Or SELECT COL_NAME FROM TBL_NAME WHERE ROW_NO=5 Regards, Ravi K The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Can a row be refered using row number?
At 03:43 AM 8/10/2006, you wrote: Hi All, Is there any way to refer a row based on the row number or row count? I just the effect as below... E.g. UPDATE TBL_NAME SET COL_NAME = xyz WHERE ROW_NO=4 Or SELECT COL_NAME FROM TBL_NAME WHERE ROW_NO=5 Regards, Ravi K Ravi K, The only way to achieve this is to use an auto-incrementing key (usually unsigned integer) which gives each row a unique id. The id is sorted according to the order in which the rows were added. Mike The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]