Aaron Williams wrote:
> 
> Hello list,
> 
> After searching the documentation on the site, as well as the archives, I
> have yet to find the answer to this question. If I have overlooked it
> somewhere, just point me in the right direction.
> 
> The question:
> 
> I have two tables, set up exactly the same, except the names of the tables
> are different.
> 
> Table 1 is called: active_users
> Table 2 is called: deleted_users
> 
> When "joe_smith" wishes to be deleted, I want to remove his entry from the
> active_users table, and place it into the delete_users table, with exactly
> the same information.
> 
> Something like: replicate * from active_users where user_name = "joe_smith"
> into table deleted_users;
> 
> All entries in Table 1 are unique by user_name (joe_smith in this case),
> but such is not the case in the deleted_users (there is more than one
> joe_smith in the world, if one cancels, we need to allow another one to
> signup), which is why I can't just add an extra column to tell if the user
> is active or not.
> 
> I could do a select from active_users, store the information, then insert
> into deleted_users, then delete from active_users, but that is three steps
> when it seems there should be an easier (more efficient) way.
> 
> Any ideas or links to archives or documentation is appreciated.
> 


Can be done in two steps, but not in one:

insert into deleted_users select * from active_where where username='joe';
delete form active_users where username='joe';

what you mention about usernames not being unique in the deleted_users table is
not a problem as long as you don't have a primary or unique key on username.. but
you should make some primary key in the delete_users table, an auto_increment
or something for maintenance purposes.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to