Re: Join question

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

 



At 4:11 PM -0500 11/29/07, Robert Cummings wrote:
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.

Table1 passwords and logins are not populated. I want to take those appearing in Table2 and place them in Table1.

Then, I need to take all the entries that are in Table2, but not in Table2, and add them to Table1.

I think (could be wrong) it's going to be a two pass operation. First, to transfer values to records in the target table (user1) that have common username with the source table (user2); Second, to add records from the source table (user2) that don't are not found in the target table (user1).

user1 Table
username   <-- common to both tables
login <-- needs to be populated
password <-- needs to be populated

user2 Table
username   <-- common to both tables
login  <-- has data
password <-- has data

I thought that --

UPDATE user1 u1, user2 u2
SET u1.login = u2.login, u1.password = u2.password
WHERE u1.username = u2.username

-- would work, but it don't.

Once I can transfer the known data, then I can work on increasing the number of entries that are found in user2 but are absent in user1.

Still floundering.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
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