On Thu, 2007-11-29 at 15:47 -0500, Wolf wrote:
> ---- tedd <[EMAIL PROTECTED]> wrote: 
> > Hi gang:
> > 
> > I'm trying to understand joins,
> > 
> > Here's the situation. I have two tables (user1, user2) in one database:
> > 
> > The common field between the two tables is "username". I want to take 
> > fields "login" and "password" from user2 and populate the same fields 
> > in user1.
> > 
> > Currently, the table user1 has 5303 entries, whereas user2 has 5909.
> > 
> > What I want at the end of this is for table user1 to have the same 
> > number of entries as table user2.
> > 
> > Now, how do I set up the query?
> > 
> > TIA for any suggestions.
> > 
> > Cheers,
> > 
> > tedd
> > 
> > PS: Side note -- will safe_mode ON cause problems with this?
> > 
> You should be only "joined" on entries with the same amounts, so if username 
> george is in both, it should join.
> 
> However if username george_by_george only exists in table 2, then you don't 
> get a join happening.
> 
> What you would instead want to do is run a loop through the second table and 
> grep the username against the first table.  If it exists, give them command 
> to write table2.pass into table1.pass  
> If it doesn't exist you want to write table2.user and table2.pass into table1

Grep? Loop? A single query will suffice. Also, he doesn't mention
wanting to clobber the passwords in table1 when the username does
already exist.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to