Re: [PHP] Join question
- From: robert@xxxxxxxxxxxxx (Robert Cummings)
- Date: Thu, 29 Nov 2007 15:49:26 -0500
On Thu, 2007-11-29 at 15:41 -0500, tedd 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?
INSERT INTO table1
(
login,
password
)
SELECT
T2.login,
T2.password
FROM
table2 AS T2
LEFT JOIN table1 as T1 ON
T1.login = T2.login
WHERE
T1.login IS NULL;
That should do it... off the top of my head :)
Cheers,
Rob.
--
............................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
............................................................
.
- References:
- Join question
- From: tedd
- Join question
- Prev by Date: Re: [PHP] Join question
- Next by Date: Re: [PHP] Join question
- Previous by thread: Join question
- Next by thread: Re: [PHP] Join question
- Index(es):