Jump to content

[SOLVED] How do I delete multiple (empty) rows in one table using phpMyAdmin?


Recommended Posts

Hello mysql experts,

 

I feel a bit dumb because I'm sure this is easy. But I want to delete a range of empty rows from a mysql table. I'm in phpMyAdmin, in Browse view.

 

To a greenhorn like me, it seems that clicking on the "Check All" feature at the bottom of the table, then clicking on the big red "x" (delete), would do the trick.

 

But no dice. It only deletes a single row at a time. (It does work with rows that have data, but not the empty ones.)

 

There aren't a lot of rows, only 363, but there's got to be an easier way to do this than one at a time.

 

Can anyone help? Thanks!

thanks for the prompt reply.

 

Definition of empty: good question. This is a table that will only ever have 124 rows. I'll populate some fields by hand, but other fields I'll populate using an INSERT query.

 

So I tested the INSERT query once, successfully, and it populated one field. So the result was a 124-row table, with one column populated.

 

Then I realized I could populate another column using INSERT. This didn't populate the column I wanted, but it did add another 124 rows to the table. These are what I mean by empty.

 

 

They are not really empty if you have rows, so what are you actually creating, just a ID?  Something has to be in that row to be a row right?

 

IF a row exists, use UPDATE and not INSERT to modify the data in it.

thanks revraz,

 

I guess you're right, if the rows exist they can't be empty. Two of the fields are "int" type, so those contain zeros, which I guess are auto-generated. The column I wanted to populate stayed empty after my failed query, which is part of the reason why I assumed the rows were empty.

 

Another reason is that I was able to select the populated rows for deletion using "check all" and phpMyAdmin indicated a range of rows in that query box above the table (in Browse view). But the query box only indicates a single row when I click "check all" in the rows that only contain the zeros.

 

 

They would only contain 0's if you populated them or if the Default is set to 0.

 

So let's get on point, what is it that you want to do exactly.

 

If you want to delete all the rows that have a 0 in a column, just do:

 

DELETE FROM table WHERE column = 0

Appreciate your time, revraz.

 

All rows have the default zeros. Half the rows also contain useful data (in one particular column, called "name") in addition to the default zeros. I want to delete the rows in which "name" is empty.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.