Skip to content Skip to sidebar Skip to footer

Delete First Element In Database Sql Query

How to delete the first element in the table of a database ? this my table structure CREATE TABLE IF NOT EXISTS `etudiant` ( `cin` varchar(8) NOT NULL, `nom` varchar(250) NOT N

Solution 1:

Was it a syntax error?

deletefrom etudiant where cin = (select cin from etudiant orderby cin limit 1) 

Solution 2:

In SQL, tables represent unordered sets. There is no such thing as the first row in a table. However, if the ordering is specified by a column (such as a date or the primary key or something), you can use LIMIT:

delete e from etudiant
    orderby cin
    limit 1;

If you want to delete an indeterminate row, you can remove the order by.

Post a Comment for "Delete First Element In Database Sql Query"