Re: Join question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---- tedd <tedd@xxxxxxxxxxxx> 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

HTH,
Wolf

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux