MySQL Forums
Forum List  »  Newbie

Re: Delete nth row in database
Posted by: Peter Brawley
Date: May 07, 2014 10:41PM

> what query would delete the 2nd entry in the database?

First, databases don't have rows; they have tables, which have rows.

Second, there is no such thing as a "second row" in a table. Row order is determined entirely by the Order By clause in the sql that fetches rows.

In relational databases like MySQL, a table row is identified by its primary key value, so in web pages like the one you describe, the code that fetches rows for display needs to keep track of the primary key value for each row so that when a user wants to perform an operation on a row, eg edit or or delete it, the code can generate the correct sql for that operation.

So, if your table does not have a primary key, give it one, then adjust the webpage code to track rows by that column.

Consider reading a primer on relational databases.

Options: ReplyQuote


Subject
Written By
Posted
Re: Delete nth row in database
May 07, 2014 10:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.