Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

my_sql, need to delete 1st row

Tags:

php

mysql

I've looked this up here and on the web in general and not found an answer.

For reasons I'll not go into, I need to delete the top row from a mysql database table, then refresh the page.

The delete is always for the top row, and independent of the row's content, so doing a select where is useless.

Seems to me I should be able to call (in my php code) this:

mysql_deleterow(0);  // delete the top row from the table

and be done with it. But oh no -- no such call that I can find.

Is there a way to just delete a table row independent of its content? (please reread above where I say 'for reasons I'll not go into' if you feel an urge to ask me 'Why do you want to do that?')

like image 838
wantTheBest Avatar asked Dec 29 '25 02:12

wantTheBest


1 Answers

Will it work for you: DELETE FROM your_table [ORDER BY field_name] LIMIT 1;

You can omit ORDER BY.

like image 101
a1ex07 Avatar answered Dec 31 '25 14:12

a1ex07



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!