Re: Join question
| From: | tedd | Date: | Thu, 29 Nov 2007 21:42:38 +0000 |
| Subject: | Re: Join question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265256@lists.php.net to get a copy of this message | ||
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