Bhupesh Kumar
Bhupesh Kumar

Reputation: 419

How to delete last row if I have a `auto increment` field also

I want to delete the last row of table.

Query:

delete from NEXG.user_type where `id`=last_insert_id()

id is auto increment key.

But it is showing 0 rows affected.

What is the reason behind this?

Upvotes: 0

Views: 108

Answers (1)

Al Amin Chayan
Al Amin Chayan

Reputation: 2500

SIMPLY:

DELETE FROM `user_type` 
ORDER BY `id` DESC
LIMIT 1

Upvotes: 6

Related Questions