Left Joining 2 tables 2 times!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Rdam
Forum Newbie
Posts: 1
Joined: Sun Jul 06, 2008 8:41 pm

Left Joining 2 tables 2 times!

Post by Rdam »

Left Joining 2 tables 2 times!
Hi there,
I have two tables, the 1st tables name is USER
2nd table name is movement

this is the record example

user
Userid Username
1 Federer
2 NADAL
3 Rod****

Movement
Owner User
3 1
3 2


Expected Result
Owner User
Rod**** Federer
Rod**** Nadal


How can i do that ?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Left Joining 2 tables 2 times!

Post by VladSun »

[sql]SELECT     User.Username, UserAlias.UsernameFROM    MovementINNER JOIN    User ON User.id = Movement.Owner INNER JOIN    User AS UserAlias ON UserAlias.id = Movement.User[/sql]
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply