Unix Technical Forum

Delete multiple rows in one go !! ??

This is a discussion on Delete multiple rows in one go !! ?? within the MySQL forums, part of the Database Server Software category; --> This is on a PHPBB forum, but I'm looking at running this as an SQL Query if possible.. I've ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:27 AM
jerryyang_la1@yahoo.com
 
Posts: n/a
Default Delete multiple rows in one go !! ??

This is on a PHPBB forum, but I'm looking at running this as an SQL
Query if possible..

I've been validating the email addresses of my users and now want to
delete some accounts based on non validated email addresses...

So I have a list of address:

account1@domain1.com
account2@domain2.com
account3@domain3.com

ETC...

Any way to delete the users based on a list like above ?? I have about
400 email addresses..

Thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:27 AM
Sean
 
Posts: n/a
Default Re: Delete multiple rows in one go !! ??


<jerryyang_la1@yahoo.com> wrote in message
news:1174467375.239943.28020@b75g2000hsg.googlegro ups.com...
> This is on a PHPBB forum, but I'm looking at running this as an SQL
> Query if possible..
>
> I've been validating the email addresses of my users and now want to
> delete some accounts based on non validated email addresses...
>
> So I have a list of address:
>
> account1@domain1.com
> account2@domain2.com
> account3@domain3.com
>
> ETC...
>
> Any way to delete the users based on a list like above ?? I have about
> 400 email addresses..
>
> Thanks
>



How are you validating the addresses?

I used to have a contacts list, which I would periodically check (on a
webpage). Checkboxes were used to add a value to the "OBSOLETE" column that
I had created.

Then

DELETE FROM CONTACTS WHERE OBSOLETE <> ""

Later, I decided to keep the invalid ones and then add functionality to the
pages that would prevent that email address from being used. So where I
wanted a list of my contacts:

SELECT * FROM CONTACTS WHERE OBSOLETE = ""

Hope you can find something useful there.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:27 AM
Captain Paralytic
 
Posts: n/a
Default Re: Delete multiple rows in one go !! ??

On 21 Mar, 08:56, jerryyang_...@yahoo.com wrote:
> This is on a PHPBB forum, but I'm looking at running this as an SQL
> Query if possible..
>
> I've been validating the email addresses of my users and now want to
> delete some accounts based on non validated email addresses...
>
> So I have a list of address:
>
> accou...@domain1.com
> accou...@domain2.com
> accou...@domain3.com
>
> ETC...
>
> Any way to delete the users based on a list like above ?? I have about
> 400 email addresses..
>
> Thanks


You can put the email addresses into their own table and use a JOIN to
drive the deletes.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 10:27 AM
jerryyang_la1@yahoo.com
 
Posts: n/a
Default Re: Delete multiple rows in one go !! ??

Thanks

I've exported the email addresses into a text file, validated them and
know have a list of known bad addresses.

Can you explain
"You can put the email addresses into their own table and use a JOIN
to
drive the deletes. "

Or any other options ??

Thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 10:27 AM
Captain Paralytic
 
Posts: n/a
Default Re: Delete multiple rows in one go !! ??

On 21 Mar, 16:01, jerryyang_...@yahoo.com wrote:
> Thanks
>
> I've exported the email addresses into a text file, validated them and
> know have a list of known bad addresses.
>
> Can you explain
> "You can put the email addresses into their own table and use a JOIN
> to
> drive the deletes. "
>
> Or any other options ??
>
> Thanks


Suppose in your `accounts` table the email column is called `email`,
you could put all the email addresses that you want deleted in another
table called `bademails` and we'll call the column `emal` again.

Then you can use the multi table delete syntax JOINing the 2 tables.

Or of course you could change your list into the contents of an IN set.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-28-2008, 10:27 AM
Captain Paralytic
 
Posts: n/a
Default Re: Delete multiple rows in one go !! ??

On 21 Mar, 16:23, "Captain Paralytic" <paul_laut...@yahoo.com> wrote:
> On 21 Mar, 16:01, jerryyang_...@yahoo.com wrote:
>
> > Thanks

>
> > I've exported the email addresses into a text file, validated them and
> > know have a list of known bad addresses.

>
> > Can you explain
> > "You can put the email addresses into their own table and use a JOIN
> > to
> > drive the deletes. "

>
> > Or any other options ??

>
> > Thanks

>
> Suppose in your `accounts` table the email column is called `email`,
> you could put all the email addresses that you want deleted in another
> table called `bademails` and we'll call the column `email` again.
>
> Then you can use the multi table delete syntax JOINing the 2 tables.
>
> Or of course you could change your list into the contents of an IN set.


Example of multi table delete:

DELETE FROM `accounts` USING `accounts` JOIN `bademails` USING(`email`)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:36 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com