Hey folks,
I am loading the database from the text file using load infile command,
what i wish to do is to delete last inserted data not just the last row i.e all the data i have loaded from text tile.I am working on MySQL.

Thanks in advance
Prankyrules

You could empty an entire table using:

truncate `table_name`;

Or, have a quick look in the table and find the first and last id's for the data you want to delete and use:

delete * from `table_name` where `id` between 100 and 1000

Replacing `table_name` and the 100 and 1000 appropriately.

R.

You could empty an entire table using:

truncate `table_name`;

Or, have a quick look in the table and find the first and last id's for the data you want to delete and use:

delete * from `table_name` where `id` between 100 and 1000

Replacing `table_name` and the 100 and 1000 appropriately.

R.

Thanks for the reply.I really appreciate.I have one more doubt when we insert data into a table.Is is sorted automatically and then inserted or it just get appended at the bottom.
Thanks

prankyrules

well it depends if you have your primary key say UserID INT AUTO_INCREMENT then all new datas are appended
ex. if your last entry before you updated it is UserID = 100 then your new data entry should start with 101 to N where n = number of new data

Hey folks,
I am loading the database from the text file using load infile command,
what i wish to do is to delete last inserted data not just the last row i.e all the data i have loaded from text tile.I am working on MySQL.

Thanks in advance
Prankyrules

Why you are importing data if you want to delete that after importing? Am I taking it wrong?

maybe its for testing... i'm a newbie too and i always do test so i can understand more how these things work...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.